我的初始视图控制器是一个标签栏控制器,在标签控制器中有几个UINavigationControllers,在其中一个UINavigationControllers中,提供了一个模态,其中另一个UINavigationController是用另一个UIViewControllers流创建的。
我需要通过推送到该视图层次结构的“最深”部分之一来响应App Delegate中收到的远程通知。
我可以重新创建一个UINavigationController并按名称启动正确的UIViewController,但是它会让用户保持高度干燥,没有其他地方可去。
有没有办法让用户回到正确的导航流程?
答案 0 :(得分:4)
我在App Delegate的didReceiveRemoteNotification方法中使用它的方式:
let rootTabbarController = self.window?.rootViewController as UITabBarController
let mainStoryboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let firstNavigationController = mainStoryboard.instantiateViewControllerWithIdentifier("firstNavVc") as UINavigationController
rootTabbarController.viewControllers![0] = firstNavigationController
let vControllerForFirstNavController = (rootTabbarController.viewControllers![0] as UINavigationController).topViewController as MainViewController
let firstDetailsNavController = mainStoryboard.instantiateViewControllerWithIdentifier("detailsNavController") as MainDetailsMenuNavigationController
let detailsVc = firstDetailsNavController.topViewController as MainDetailsViewController
firstNavigationController.presentViewController(firstDetailsNavController, animated: false, completion: nil)
let specificInfoVc = mainStoryboard.instantiateViewControllerWithIdentifier("sDetails") as SpecificDetailsViewController
firstDetailsNavController.pushViewController(specificInfoVc, animated: true)