在取消分配时尝试加载视图控制器的视图。 CoreSpotlight

我在我的应用程序中集成了CoreSpotlight 。 我希望用户在聚光灯搜索中找到需要的信息,用户将在DetailViewController信息中打开此信息,在DetailViewController打开。 我做到了,聚光灯效果很好,但是当应用程序打开时我看到这个错误尝试在取消分配时加载视图控制器的视图是不允许的并且可能导致未定义的行为(UIAlertController:0x1245a0560)虽然我不使用UIAlertController 。 我在AppDelegate func中调用了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") } } 

如果您没有实现willContinueUserActivityWithType,或者它返回false,则表示iOS应该处理活动。 在这种情况下,它可以显示UIAlertController。 因此,要在此委托调用中为此活动取消此警告返回true:

func application(application: UIApplication, willContinueUserActivityWithType userActivityType: String) -> Bool { return true }