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;

    }

     

     

  • 相关阅读:
    085 Maximal Rectangle 最大矩形
    084 Largest Rectangle in Histogram 柱状图中最大的矩形
    083 Remove Duplicates from Sorted List 有序链表中删除重复的结点
    082 Remove Duplicates from Sorted List II 有序的链表删除重复的结点 II
    081 Search in Rotated Sorted Array II 搜索旋转排序数组 ||
    080 Remove Duplicates from Sorted Array II 从排序阵列中删除重复 II
    079 Word Search 单词搜索
    078 Subsets 子集
    bzoj2326: [HNOI2011]数学作业
    bzoj2152: 聪聪可可
  • 原文地址:https://www.cnblogs.com/yuwei0911/p/5881690.html
Copyright © 2011-2022 走看看