在我的故事板上,我有一个嵌入在导航控制器中的集合视图控制器。现在从集合视图的单元格,我以编程方式打开第二个视图控制器(称为TwoPicsViewController),如下所示:
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的视图控制器。
我错过了其他什么吗?
由于
答案 0 :(得分:1)
要将新的UIViewController
推送到导航堆栈,您应该使用:
self.navigationController?.pushViewController(nextViewController, animated: true)
而不是:
self.present(nextViewController, animated:true, completion:nil)
答案 1 :(得分:0)
你没有把新的vc放在导航堆栈上,试试这个:
performSegue(withIdentifier: "Segue Name", sender: nil)
在故事板上选择Segue,属性检查器,标识符=" Segue Name"