zoukankan      html  css  js  c++  java
  • core spotlight

    _data = @[@"图片1" ,@"图片2" , @"图片3"];

     

     

        NSMutableArray * arr = [NSMutableArray arrayWithCapacity:10];

        

     

        

        

        [_data enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {

            

            CSSearchableItemAttributeSet * attributeSet = [[CSSearchableItemAttributeSet alloc]initWithItemContentType:@"view"];

            

            attributeSet.title = obj;

            

            NSLog(@"%@" , obj);

            

            

            attributeSet.contentDescription = [NSString stringWithFormat:NSLocalizedString(@"easy way to open %@", nil),obj];

            

            UIImage * thumbImage = [UIImage imageNamed:[NSString stringWithFormat: @"%@.jpg" , obj]];

            

            attributeSet.thumbnailData = UIImagePNGRepresentation(thumbImage);

            

            CSSearchableItem * item = [[CSSearchableItem alloc]initWithUniqueIdentifier:[NSString stringWithFormat:@"1%@" , obj] domainIdentifier:@"demo" attributeSet:attributeSet];

            

            

            [arr addObject:item];

            

            

        }];

        

        [[CSSearchableIndex  defaultSearchableIndex]indexSearchableItems:arr completionHandler:^(NSError * _Nullable error) {

            

            if (!error) {

                

                

                NSLog(@"%@ ", error.localizedDescription);

                

                

            }

            

        }];

        

     

     

     

    实现:(实现跳转)

    -(BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler

    {

        

        

        NSLog(@"%@" , userActivity.userInfo);

        

        

        NSString * indetifier = userActivity.userInfo[@"kCSSearchableItemActivityIdentifier"];

        

        NSString * subStr = [indetifier substringFromIndex:0];

        

        NSLog(@"%@" , subStr);

        

           UINavigationController * nav  = (UINavigationController *)[UIApplication sharedApplication].keyWindow.rootViewController;

        if ([subStr isEqualToString:@"图片1"]) {

            

         

            

            [nav popToRootViewControllerAnimated:YES];

            

            

        }else if ([subStr isEqualToString:@"图片2"]){

            

            BG2ViewController * bg2 = [[BG2ViewController alloc]init];

            

            [nav pushViewController:bg2 animated:YES];

            

            

        }else{

            

            BG3ViewController * bg3 = [[BG3ViewController alloc]init];

            

            [nav pushViewController:bg3 animated:YES];

        }

        

        

        

        return YES;

    }

     

     

  • 相关阅读:
    PYSpark DataFrame
    wheel用户组
    CURD是什么?
    mysql binlog日志清理
    skype的图片默认保存路径
    bootstrap使用总结
    库表批量新增id字段
    谷粒商城-问题汇总
    开发工具问题汇总
    feign客户端,参数无法传递复杂对象
  • 原文地址:https://www.cnblogs.com/yuwei0911/p/5881690.html
Copyright © 2011-2022 走看看