我试图在Core Spotlight的帮助下搜索我的应用程序内容.一切都很好,标题和描述来了,但没有缩略图.
这是我正在尝试的:
CSSearchableItemAttributeSet *attributeSet = [[CSSearchableItemAttributeSet alloc]initWithItemContentType:(Nsstring *)kUTTypeImage]; attributeSet.title = @"My First Spotlight Search"; attributeSet.contentDescription = @"This is my first spotlight Search"; attributeSet.keywords = [NSArray arrayWithObjects:@"Hello",@"Welcome",@"Spotlight",nil]; UIImage *image = [UIImage imageNamed:@"searchIcon.png"]; NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(image)]; attributeSet.thumbnailData = imageData; CSSearchableItem *item = [[CSSearchableItem alloc]initWithUniqueIdentifier:@"com.deeplink" domainIdentifier:@"spotlight.sample" attributeSet:attributeSet]; [[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:@[item] completionHandler: ^(NSError * __nullable error) { if (!error) NSLog(@"Search item indexed"); }];
解决方法
iOS 9 beta 1发行说明指出缩略图尚未用于搜索结果.见:
https://developer.apple.com/library/prerelease/ios/releasenotes/General/RN-iOSSDK-9.0/index.html
原文地址:https://www.jb51.cc/iOS/333369.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。