- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我花了很多时间来寻找 NSUserActivity 相对于 CoreSpotlight 的好处,但实际上我找不到任何东西。
实际上,它无法索引我们通过 NSUserActivity 设置的项。我在下面附上了我的代码片段,它应该按照苹果文档工作,但它不会。
let personName = "Jon Doe"
let activity = NSUserActivity(activityType: "com.SearchAPIs.test”)
activity.userInfo = ["name": "Jon Doe"]
activity.title = person.name
let keywords = personName.componentsSeparatedByString(" ")
activity.keywords = Set(keywords)
activity.eligibleForSearch = true
activity.eligibleForPublicIndexing = true
activity.expirationDate = NSDate().dateByAddingTimeInterval(16666600)
activity.becomeCurrent()
我想找到答案
Why we need to use NSUserActivity in way of search, since it can be possible with CoreSpotlight?
最佳答案
根据苹果文档
To guarantee that the activity and its metadata get indexed, you must hold a strong reference to the activity until it gets added to the index. There are two ways to do this: The first way is to assign the activity to a property in the controller object that creates the activity. The second way is to use the userActivity property of the UIResponder object. If you use the second way, you need to set the metadata—such as information in the userInfo property—in the updateUserActivityState: method; otherwise, the metadata you set on the activity will not be persisted.
你的事件在被索引之前被释放,最好使用 self
来保留。
第二个问题的答案对我来说仍然是个谜。
也许它像性能,索引中没有项目,重要的是 CoreSpotlight 不提供的公共(public)索引。我们必须再等一会儿才能得到您问题的答案。
关于objective-c - NSUserActivity 和 CoreSpotlight 的使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32134733/
我在使用我的应用程序中的 mapItem 实现 NSUserActivity 时遇到了一些问题。 我想要的只是能够在应用程序切换器中使用“获取路线”建议,就像 Foursquare 所做的那样: 我在
我正在尝试使用 NSUserActivity 在我的 iPhone 和 iPad 之间测试 iOS 8.1 切换功能。为此,我尝试既实现自己的解决方案,又使用 Apple 的 PhotoHandoff
在 iOS 9 中,NSUserActivities 可以与 Siri 一起使用,例如,“Siri,请在一小时内提醒我”,在她知道“THIS”是什么的上下文的情况下创建提醒。有没有办法以编程方式执行此
我有一个关于 NSUserActivity 的 userInfo 属性的快速问题。 NSString *activity = @"com.test.activity"; NSUserActivity
以下是我试图实现的代码,使应用程序事件和状态可搜索但无法在 iOS 搜索中显示 NSUserActivity *userActivity = [[NSUserActivity alloc]initWi
我正在努力思考 NSUserActivity,但我并不完全确定如何正确使用它们。我已经像这样正确设置了我的 NSUserActivity: let attributeSet = CSSearchabl
我正在尝试使用通用链接从应用程序 A 打开应用程序 B,如下所示: @IBAction func openButtonPressed(_ sender: Any) { if let appUR
这就是我注册 UserActivity 的方式。 我得到了捷径并且功能有效。 但是我得到的应用程序图标是缩略图,而不是我设置的图标, func registerUserActivity(compone
我试图让我的 NSUserActivity 被 iOS 中 Spotlight 中的私有(private)索引索引。我已按照 Apple's Index Activities and Navigati
我正在使用 NSUserActivities 实现 iOS9 搜索索引。根据文档 NSUserActivity应该有一个名为 contentAttributeSet 的属性,用于向搜索项添加更多内容。
我有一个应用程序,您可以在其中找到我们大学的员工,并通过电子邮件与他们联系。当你找到某人并查看详细信息时,将创建一个 NSUserActivity: if (SYSTEM_VERSION_GREATE
我正在尝试将我自己的事件添加到 osx 10.11 上的 Spotlight 搜索结果中。但经过多次尝试,我无法通过关键字搜索或标题搜索进入 Spotlight 搜索结果。 { self.us
所以目前正在测试一些 ios9 beta 功能,但是 NSUserActivity 类已经有一段时间了,它用于切换。 基本上就是这样。当应用启动 NSUserActivity 时,我可以看到 laun
我阅读了一些教程,发现 NSUserActivity 用于用户进行事件时的索引信息,Core Spotlight 用于索引应用程序中的一组内容数据。 使用 NSUserActivity var act
我正在使用 NSUserActivity 定义应用程序函数,因此它会出现在 Spotlight 和 Siri 快捷方式中: let activity = NSUserActivity(activity
在WWDC2015看iOS9搜索API的视频时,有一个demo是这样的: var activity:NSUserActivity = NSUserActivity(activityType:"com.
我同时使用 NSUserActivity 和 Core Spotlight 来索引我应用程序中的内容。我使用 Core Spotlight 的原因是因为我想在用户访问(打开)它之前索引这些内容。 我面
我正在快速实现 CallKit,我在直接从最近的日志中进行调用时遇到了 NSUserActivity 问题。 在最近的日志中点击我的应用条目时,我的应用正在启动,但 AppDelegate 的任何方法
使用 Xcode 10(测试版 6)我可以毫无问题地编写和运行以下代码: import Intents func test() { let activity = NSUserActivity(
我已经在我们的应用程序中实现了 Handoff,当应用程序在前台或后台运行时,它可以很好地用于 Web 到应用程序的切换,反之亦然。 但是,如果应用未运行,那么如果用户从 Web 到应用切换启动应用,
我是一名优秀的程序员,十分优秀!