- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
是否可以使用iOS9的新特性如NSUserActivity
和CoreSpotlight
,但还是将我的Development Target设置为8.2,这样iOS8的用户仍然可以使用应用程序?
我假设我只需要检查 iOS 版本号或使用 respondsToSelector:
。
这是正确的吗?
最佳答案
是的,我在我的一个应用程序中执行此操作(实际上有一个 iOS 7 的部署目标)。做起来很简单。只需确保 CSSearchableIndex
类存在,使 CoreSpotlight
框架可选,并正确编写代码以防止较新的 API 在具有较早版本 iOS 的设备上运行。
您甚至可以保护代码,以便它在 Xcode 6 下编译(如果您出于某种原因这样做的话)。
例子:
// Ensure it only compiles with the Base SDK of iOS 9 or later
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 90000
// Make sure the class is available and the device supports CoreSpotlight
if ([CSSearchableIndex class] && [CSSearchableIndex isIndexingAvailable]) {
dispatch_async(_someBGQueue, ^{
NSString *someName = @"Some Name";
CSSearchableIndex *index = [[CSSearchableIndex alloc] initWithName:someName];
// rest of needed code to index with Core Spotlight
});
}
#endif
在您的应用委托(delegate)中:
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 90000
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray *restorableObjects))restorationHandler {
if ([[userActivity activityType] isEqualToString:CSSearchableItemActionType]) {
// This activity represents an item indexed using Core Spotlight, so restore the context related to the unique identifier.
// The unique identifier of the Core Spotlight item is set in the activity’s userInfo for the key CSSearchableItemActivityIdentifier.
NSString *uniqueIdentifier = [userActivity.userInfo objectForKey:CSSearchableItemActivityIdentifier];
if (uniqueIdentifier) {
// process the identifier as needed
}
}
return NO;
}
#endif
关于ios - 使用 NSUserActivity 和 CoreSpotlight 但仍将 iOS8 设置为部署目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32875794/
文档提到: https://developer.apple.com/reference/corespotlight/cssearchableindex?language=objc In batch m
我想让我的应用程序为 Spotlight 索引做好准备,所以我得到了下面的代码来向 Core Spotlight 添加一个项目: CSSearchableItemAttributeSet *attri
在我的 IOS9 应用程序中,我可以使用 CoreSpotlight 库将数据添加到 Spotlight 的索引(即,当我使用 Spotlight 搜索框进行搜索时,我添加到索引的内容会显示出来)。
您好,我正在尝试在我的应用中实现 CoreSpotlight。 索引时我需要每次都运行这个还是在第一次安装应用程序时运行一次就足够了?如果应用被删除,我需要重新索引吗? 这是我使用的代码: - (vo
我正在使用 CoreSpotLight api 来索引一些内容。出于某种原因,我在搜索时找不到数据聚光灯。 let atset:CSSearchableItemAttributeSet = CSSea
我希望我的设备能够根据聚光灯人物索引预测谁在给我打电话。我已将人员信息上传到聚光灯索引,并且系统在我搜索时提供信息,但在有人打电话时则不提供信息。下面的代码做了所有这些事情,我不明白出了什么问题 if
在 WWDC session 中搜索 API 简介。他们显示带有调用按钮的 Airbnb 应用程序的搜索结果。据我所见,我认为结果是使用 CSSearchableItemAttributeSet 创建
我正在使用 CoreSpolight 框架为 CSSearchableItem 赋值。我想优化图片加载。 func setupSearchableContent(moviesInfo:NSMutabl
我正在尝试将聚光灯集成添加到我的 Mac 应用程序,但出现错误。步骤如下: 我创建了一个新的 cocoa 应用 我已将 CoreSpotlight 和 CoreServices 框架添加到项目buil
我正尝试在 Core Spotlight 的帮助下让我的应用内内容可搜索。一切正常,标题和描述都出现了,但没有缩略图。 这是我正在尝试的: CSSearchableItemAttributeSet *
CoreSpotlight 示例: https://applidium.com/en/news/ios9_search_api/ Spotlight 索引扩展示例: http://apprize.in
我花了很多时间来寻找 NSUserActivity 相对于 CoreSpotlight 的好处,但实际上我找不到任何东西。 实际上,它无法索引我们通过 NSUserActivity 设置的项。我在下面
我正在尝试构建一个测试应用程序,该应用程序使用 CoreSpotlight 使内容可在 iOS Spotlight 中搜索。目前,我将其设置为每当用户点击刷新按钮时,它都会发出服务器请求,然后 del
我正在使用“半静态”CoreSpotlight db 在需要时动态创建和替换 Spotlight Search 的概念证明。 这是我用于删除和重新创建整个内容的代码(假设 items 是 CSSear
如何在 CoreSpotlight 框架和 NSUserActivity 中选择最适合搜索编程的框架。 最佳答案 核心聚光灯 不要求用户访问内容以对其进行索引(在任何时候索引内容) 私有(privat
我有以下几行代码: var attributes = new CSSearchableItemAttributeSet (); attributes.Title = "Title"; attribut
是否可以使用iOS9的新特性如NSUserActivity和CoreSpotlight,但还是将我的Development Target设置为8.2,这样iOS8的用户仍然可以使用应用程序? 我假设我
是否有 corespotlight 搜索功能的示例代码 - iOS 9 API?如果可以查看示例代码来实现/测试,我将不胜感激。 最佳答案 创建一个新的 iOS 项目并将 CoreSpotlight
我正在努力将 CoreSpotlight 框架功能与应用程序集成,并尝试在 iOS 8.3 设备上运行它。每次我得到: dyld: Library not loaded: /System/Librar
我是一名优秀的程序员,十分优秀!