swift - 以编程方式打开 View Controller 并且看不到导航栏。 swift 3

标签 swift uinavigationcontroller uicollectionview uinavigationbar

在我的 Storyboard上,我有一个嵌入在导航 Controller 中的 Collection View Controller 。现在从 Collection View 的单元格中,我以编程方式打开第二个 View Controller (称为 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 打开时,我根本看不到导航栏。在 Storyboard上,我将 TwoPicsViewController 连接到第一个带有 segue show 的 View Controller 。

我还漏掉了什么吗?

谢谢

最佳答案

要将新的 UIViewController 推送到导航堆栈,您应该使用:

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

代替:

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

关于swift - 以编程方式打开 View Controller 并且看不到导航栏。 swift 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44398706/

相关文章:

iphone - 如何在导航 Controller 栏上叠加 View ?

ios - 根据collectionView.tag定义collectionView

swift 3 : button on collectionview

ios - ios/swift 中的 Root View Controller 发生了什么

swift - 如何在 Swift 中处理来自 C 的缓冲字符串?

swift - 如何获得特定的日期格式?

arrays - TableView 没有结果错误?

ios - UIView segue UINavigationBar 闪烁

ios - 在 Swift 中更改导航栏

ios - swift 中的自定义 Collection View 单元格