当我单击推送通知时,我想导航到特定的视图控制器。导航到单击具有Reveal的推送通知时的特定视图
我在didReceiveRemoteNotification方法中编写了这段代码。
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "deals") as! FYIDealsVC
let naviVC:UINavigationController? = self.window?.rootViewController?.revealViewController().frontViewController as? UINavigationController
naviVC?.pushViewController(vc, animated: true)
}
但它给我这个崩溃的应用程序的错误。
fatal error: unexpectedly found nil while unwrapping an Optional value
有很多带有导航控制器的帖子或只是提供了viewcontroller。但我想用揭示导航到具体的视图。
任何帮助将不胜感激。
你确定给定屏幕的故事板ID是 “交易”,它具有类'FYIDealsVC'? – the4kman
是的,在这一行中只有它分解了 让naviVC:UINavigationController? = self.window?.rootViewController?.revealViewController()。frontViewController as? UINavigationController – NavodaP
你确定你正在获取导航控制器的对象调试这一行我认为你在这一行self.window?.rootViewController?.revealViewController()。 UINavigationController – Pushpendra