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;

    }

     

     

  • 相关阅读:
    [网络收集]jquery,JavaScript操作iframe
    [网络收集]打造站内搜索引擎
    Delphi XE2 之 FireMonkey 入门(8) TImage
    Delphi XE2 之 FireMonkey 入门(9) TBitmap
    Delphi XE2 之 FireMonkey 入门(10) 常用结构 TPoint、TPointF、TSmallPoint、TSize、TRect、TRectF 及相关方法
    Delphi XE2 之 FireMonkey 入门(6) TLine、TEllipse、TCircle、TPie、TArc、TRectangle、TRoundRect、TCalloutRectangle
    Delphi XE2 之 FireMonkey 入门(11) 控件居中、旋转、透明
    Delphi XE2 之 FireMonkey 入门(5) TAlphaColor
    Delphi XE2 之 FireMonkey 入门(7) TText 与 TFont
    Delphi XE2 之 FireMonkey 入门(14) 滤镜: 概览
  • 原文地址:https://www.cnblogs.com/yuwei0911/p/5881690.html
Copyright © 2011-2022 走看看