Spotlight

作者: 超_iOS | 来源:发表于2017-03-10 14:07 被阅读29次

何为App Search?在iOS9之前,用户通过spotlight只能搜索app的名字,或者苹果自带app的一些内容,比如搜索通讯录、备忘录中的内容。iOS9开始,用户可以通过spotlight搜索网页内容或者任何app内的数据。


Paste_Image.png

如图,网上找的.

有空再加注释

- (void)spotlight{
    CSSearchableItemAttributeSet *firstSet = [[CSSearchableItemAttributeSet alloc] initWithItemContentType:@"firstSet"];
    firstSet.title = @"主人,世上只有主人好";
    firstSet.contentDescription = @"主人不要冷落我,点点我嘛";
    firstSet.thumbnailData = UIImagePNGRepresentation([UIImage imageNamed:@"没有"]);
    NSArray * firstSearchKey = @[@"直播",@"美女",@"QQ"];
    firstSet.contactKeywords = firstSearchKey;
    CSSearchableItem *firstItem = [[CSSearchableItem alloc] initWithUniqueIdentifier:@"firstItem" domainIdentifier:@"first" attributeSet:firstSet];
    
    CSSearchableItemAttributeSet *secondSet = [[CSSearchableItemAttributeSet alloc] initWithItemContentType:@"secondSet"];
    secondSet.title = @"bibi求宠幸";
    secondSet.contentDescription = @"主人,点我有惊喜呦";
    secondSet.thumbnailData =  UIImagePNGRepresentation([UIImage imageNamed:@"没有"]);
    NSArray *secondKey = @[@"微信",@"视频",@"支付宝"];
    secondSet.contactKeywords = secondKey;
    CSSearchableItem *secondItem = [[CSSearchableItem alloc] initWithUniqueIdentifier:@"secondItem" domainIdentifier:@"second" attributeSet:secondSet];
    
    
    NSArray *items = @[firstItem,secondItem];
    
    [[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:items completionHandler:^(NSError * _Nullable error) {
        if (error) {
            DLog(@"%@,搜索设置失败");
        }else{
            DLog(@"搜索设置成功");
        }
    }];
}
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler{
    NSString *idetifier  = userActivity.userInfo[@"kCSSearchableItemActivityIdentifier"];
    NSLog(@"%@搜索标识符",idetifier);
    
    if ([idetifier isEqualToString:@"firstItem"]) {
        DLog(@"点击111%@",self.window.rootViewController);
        DLog(@"%@",[self getsCurrentVC]);
        
        
    }else if ([idetifier isEqualToString:@"secondItem"]){
        DLog(@"点击222");
        DLog(@"%@",[self getsCurrentVC]);
    }
    

    
    return YES;
}

相关文章

  • 一款厉害的性能测试工具

    Spotlight下载地址: http://spotlight-on-unix.software.informer...

  • Mac实用操作技巧(一)

    使用Spotlight进行数学计算、单位转换 在调出Spotlight后,可以直接在Spotlight输入框中输入...

  • 程序员的Mac入门-必备概念-认识 Mac 的 Spotligh

    快捷键调用 Spotlight: command + 空格 官网介绍 Spotlight

  • 2016.5.6

    4A+B spotlight聚光灯 Tina loves to be in the spotlight,She c...

  • spotlight

    《聚焦》 人性的扭曲,越是满嘴道理的人,越容易拿着正义的旗帜,做卑鄙的事情。聚焦波士顿的神父就是这样的人,打着主的...

  • Spotlight

    何为App Search?在iOS9之前,用户通过spotlight只能搜索app的名字,或者苹果自带app的一些...

  • Spotlight

    返回上级 在 windows, 曾经把快捷方式放到 system32 目录下, 通过 win + R 来启动程序....

  • SPOTlight

    这个是官网示例数,把自己的数据填进去就行。这个好的一点是可以看出来每一个spot中包括的细胞类型,我简直太需要这个...

  • iOS应用内搜索CoreSpotlight使用

    点击下载 Demo 一、Core Spotlight 简介 iOS9 推出了 Core Spotlight 框架,...

  • iOS 9 的search API(Core Spotlight

    iOS 9 Core Spotlight 框架 Core Spotlight框架用来索引应用内的内容。它创建...

网友评论

    本文标题:Spotlight

    本文链接:https://www.haomeiwen.com/subject/wxdngttx.html