【问题标题】:Attempting to load the view of a view controller while it is deallocating. CoreSpotlight尝试在解除分配时加载视图控制器的视图。核心聚焦
【发布时间】:2015-10-08 10:00:31
【问题描述】:

我在我的应用程序中集成了CoreSpotlight。我希望用户在聚光灯搜索中找到需要信息,并且在用户在聚光灯中打开此信息后,信息将在DetailViewController 中打开。我做到了,聚光灯工作得很好,但是当应用程序打开时我看到这个错误不允许在解除分配时尝试加载视图控制器的视图,并且可能导致未定义的行为(UIAlertController:0x1245a0560) 虽然我不使用UIAlertController。我在 AppDelegate func 中制作了调用 UITableViewController 的函数,该函数必须按索引打开对象。但它没有出现。 showData() 中仍有错误performSegueWithIdentifier("show", sender: nil)原因:'Receiver () has no segue with identifier 'show''。虽然我添加了 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")
    }
}

【问题讨论】:

    标签: ios swift2 uistoryboardsegue corespotlight


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多