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;

    }

     

     

  • 相关阅读:
    deepin系统换软件下载源&商店卡死刷新空白问题解决
    php数组和json数组之间的互相转化
    php 获取数组个数的方法
    php 三种文件下载的实现
    win10激活
    deepin/linux安装exe
    deepin连接windows
    deepin升级微信
    deepin安装.net core
    在Deepin 15.9下安装Wine 4.0
  • 原文地址:https://www.cnblogs.com/yuwei0911/p/5881690.html
Copyright © 2011-2022 走看看