我尝试在用户点击"新消息后打开特定控制器"推送通知,但我找不到如何导航到会话详细控制器。
以下是didReceiveRemoteNotification()
var rootViewController = self.window!.rootViewController
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
var setViewController = mainStoryboard.instantiateViewControllerWithIdentifier("JSQVCTest") as! JSQVCTest
setViewController.currentConversation = currentConversation
rootViewController!.navigationController!.popToViewController(setViewController, animated: false)
当我运行此操作时,应用程序在最后一行崩溃,因为rootViewController!.navigationController
为nil
,我收到了消息
致命错误:在解包可选值时意外发现nil
我的故事板看起来像这样:
var rootViewController = self.window!.rootViewController
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let navigationViewController = mainStoryboard.instantiateViewControllerWithIdentifier("navigationController") as! UINavigationController
var setConversationViewController = mainStoryboard.instantiateViewControllerWithIdentifier("conversationController") as! ConversationListTableViewController
navigationViewController.pushViewController(setConversationViewController, animated: false)
var setMessageViewController = mainStoryboard.instantiateViewControllerWithIdentifier("JSQVCTest") as! JSQVCTest
navigationViewController.pushViewController(setMessageViewController, animated: true)