任何人都可以在SearchApi的NSUserActivity功能中为我提供教程或示例代码。我正在做很多关于此功能的RND,但没有得到适当的代码。
答案 0 :(得分:2)
一个例子是:
let activity = NSUserActivity(activityType: "com.tutsplus.iOS-9-Search.displayShow")
activity.userInfo = ["name": detailItem.name, "genre": detailItem.genre, "time": detailItem.time]
activity.title = detailItem.name
var keywords = detailItem.name.componentsSeparatedByString(" ")
keywords.append(detailItem.genre)
activity.keywords = Set(keywords)
activity.eligibleForHandoff = false
activity.eligibleForSearch = true
//activity.eligibleForPublicIndexing = true
//activity.expirationDate = NSDate()
activity.becomeCurrent()
有关更多信息和示例,请参阅this link