我有一个ViewController,当从锁定屏幕打开推送通知时,我想显示该ViewController。
视图控制器嵌入在视图控制器链中,该链为:

TabbedBarController(root)-> NavigationController0-> ViewController0-> ViewController1-> ViewControllerIWant

我要传递给ViewControllerIWant的推送通知中有两个变量

到目前为止,我有:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let rootVC = storyboard.instantiateViewControllerWithIdentifier("HomeVC") as! UITabBarController // HomeVC is the TabbedBarController
let NaviVC = storyboard.instantiateViewControllerWithIdentifier("NavigationController0") as! UINavigationController // NavigationController0 is the Navigation Controller for this stack

let ViewController0 = storyBoard.instantiateViewControllerWithIdentifier("ViewController0") as ViewController0
let ViewController1 = storyBoard.instantiateViewControllerWithIdentifier("ViewController1") as ViewController1
let ViewControllerIWant = storyBoard.instantiateViewControllerWithIdentifier("ViewControllerIWant") as ViewControllerIWant

// Pass the Variables into ViewControllerIWant
ViewControllerIWant.Variable0 = "This is the first Variable"
ViewControllerIWant.Variable1 = "this is the second variable"
// Load the VC
self.presentViewController(ViewControllerIWant, animated:true, completion:nil)

我可以直接加载ViewControllerIWant,但是然后松开导航和标签控制器,因此向后移动需要关闭应用程序并重新加载。
我如何嵌套VC,以便当用户滑动此通知时它加载ViewControllerIWant?

最佳答案

您可以只设置navigationController的viewControllers。并显示当前的navigationController。

在您的示例中,您应该在行之后添加(我将所有内容都更改为小写。您实际上不应该将大写用作变量)

viewControllerIWant.variable1 = "this is the second variable"
naviVC.viewControllers = [viewController0, viewController1, viewControllerIWant]

关于ios - 快速导航到ViewController那就是3个窗口深,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38463028/

10-09 13:01