Search code examples
iosswiftviewcontrollernavigationbar

Swift - Present another view controller with its navigation bar


I have two ViewControllers -- one with storyboard and one without. Both of those view controllers have their own Navigation Bar at the top. Now when I use self.presentViewController(editorViewController, animated: true, completion: nil) my editorViewController comes up but without its Navigation bar.

Any ideas how to fix this?


Solution

  • I fixed the problem using the following code:

    let editorViewController = IMGLYMainEditorViewController()
    let navEditorViewController: UINavigationController = UINavigationController(rootViewController: editorViewController)
    self.presentViewController(navEditorViewController, animated: true, completion: nil)
    

    I just added the navEditorViewController as it made my navigation bar with its items to appear.