尝试在取消分配时加载视图控制器的视图. CoreSpotlight [英] Attempting to load the view of a view controller while it is deallocating. CoreSpotlight

查看:96
本文介绍了尝试在取消分配时加载视图控制器的视图. CoreSpotlight的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将CoreSpotlight集成到了我的应用中.我希望用户可以在Spotlight搜索中找到需要的信息,并在用户在Spotlight中打开此信息之后在DetailViewController中打开信息.我做到了,Spotlight正常工作,但是当应用程序打开时,我看到此错误不允许在尝试分配视图时尝试加载视图控制器的视图,这可能会导致未定义的行为(UIAlertController:0x1245a0560)尽管我不使用UIAlertController.我在AppDelegate函数中创建了一个函数,该函数调用UITableViewController的函数,该函数必须按索引打开对象.但是它没有出现. showData()performSegueWithIdentifier("show", sender: nil) 原因仍然存在错误:"Receiver()没有标识为"show"的提示.尽管我添加了segue(带有显示名称),并且当我通常选择单元格时它可以工作.请帮助我.

I integrate CoreSpotlight in my app. I want that user will find need information in spotlight search and after user will open this information in spotlight information opens in DetailViewController. I made it, spotlight works nice, but when application is opening I see this error Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (UIAlertController: 0x1245a0560) although I don't use UIAlertController. I made in AppDelegate func which call function of UITableViewController which must to open object by index. But it is not appear. Still there is an error in showData() performSegueWithIdentifier("show", sender: nil)reason: 'Receiver () has no segue with identifier 'show''. Although I add segue ( with show name) and it works when I usually select cell. Please help me.

    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:

If you don't implement willContinueUserActivityWithType or if it returns false, it means that iOS should handle activity. And in this case it can show UIAlertController. So to get rid this warning return true for your activity in this delegate call:

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

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

这篇关于尝试在取消分配时加载视图控制器的视图. CoreSpotlight的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆