1.Spotloight是什么?
Spotlight在iOS9上做了一些新的改进, 也就是开放了一些新的API, 通过Core Spotlight Framework你可以在你的app中集成Spotlight。集成Spotlight的App可以在Spotlight中搜索App的内容,并且通过内容打开相关页面。
Demo演示
2.如何集成Spotlight
a.添加所需要的框架
复制代码
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 90000
#import <CoreSpotlight/CoreSpotlight.h>
#import <MobileCoreServices/MobileCoreServices.h>
#endif
注,很多APP都是支持iOS9以下的,因此加入#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 90000,可以解决iOS9以下设备运行崩溃的问题
b.创建CSSearchableItemAttributeSet 对象
复制代码
CSSearchableItemAttributeSet *attributeSet = [[CSSearchableItemAttributeSet alloc] initWithItemContentType:(NSString *)kUTTypeImage];
attributeSet.title = spotlightTitle; // 标题
attributeSet.keywords = keywords; // 关键字,NSArray格式
attributeSet.contentDescription = spotlightDesc; // 描述
attributeSet.thumbnailData = photo; // 图标, NSData格式
// 把图片转换成NSData的方法











