以编程方式打开视图控制器,不看导航栏。 Swift 3

问题描述:

在我的故事板上,我有一个嵌入导航控制器的收藏视图控制器。现在从集合视图的细胞,我programaticly打开第二个视图控制器(称为TwoPicsViewController),像这样:以编程方式打开视图控制器,不看导航栏。 Swift 3

let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil) 

      let nextViewController = storyBoard.instantiateViewController(withIdentifier: "TwoPicsViewController") as! TwoPicsViewController 


      self.present(nextViewController, animated:true, completion:nil) 

我TwoPicsViewController打开然而,当,我没有看到导航栏在所有。在故事板上,我将TwoPicsViewController连接到第一个视图控制器并带有一个segue show。

我失去了什么东西?

感谢

若要推动新UIViewController到导航堆栈,你应该使用:

self.navigationController?.pushViewController(nextViewController, animated: true) 

相反的:

self.present(nextViewController, animated:true, completion:nil) 

你是不是把新的VC导航堆栈上,试试这个:

performSegue(withIdentifier: "Segue Name", sender: nil) 

并在Storyboard上选择Segue,属性检查器,identifier =“Segue Name”