我在我的应用程序中集成了CoreSpotlight。我希望用户会在聚光灯搜索中找到需要的信息,然后用户将在聚光灯下打开这些信息,在DetailViewController中打开。我做到了,聚光灯工作得很好,但是当应用程序打开时,我看到这个错误,试图加载视图控制器的视图是不允许的,并且可能导致未定义的行为(UIAlertController: 0x1245a0560),尽管我不使用UIAlertController。我使用AppDelegate函数调用UITableViewController函数,该函数必须通过索引打开对象。但它并没有出现。尽管如此,showData() performSegueWithIdentifier("show", sender: nil)中还是有一个错误:'Receiver ()没有带有标识符‘show’的segue。虽然我添加了segue (带有显示名称),但是当我通常选择单元格时,它可以工作。请帮帮我。
AppDelegate
func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) -> Void) -> Bool {
if userActivity.activityType == CSSearchableItemActionType {
if let identifier = userActivity.userInfo?[CSSearchableItemActivityIdentifier] as? String {
print(identifier)
checkWord = identifier // checkWord is String
let tableC = TableViewController()
tableC.showData()
return true
}
}
return false
}
func showData() {
let matchString = appDel.checkWord
if mainArray.contains(matchString) {
let ind = mainArray.indexOf(matchString)!
let indexPathMain = NSIndexPath(forItem: ind, inSection: 0)
print(indexPathMain)
self.tableView.selectRowAtIndexPath(indexPathMain, animated: true, scrollPosition: UITableViewScrollPosition.None)
performSegueWithIdentifier("show", sender: nil)
print("Show data")
}
}发布于 2016-01-15 23:10:20
如果您不实现willContinueUserActivityWithType,或者如果它返回false,这意味着iOS应该处理活动。在这种情况下,它可以显示UIAlertController。因此,要消除此警告,请在此委托调用中为您的活动返回true:
func application(application: UIApplication, willContinueUserActivityWithType userActivityType: String) -> Bool { return true }
https://stackoverflow.com/questions/33012529
复制相似问题