Swift - Present another view controller with its navigation bar

Vasil Nunev picture Vasil Nunev · Mar 22, 2016 · Viewed 20.3k times · Source

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?

Answer

Vasil Nunev picture Vasil Nunev · Mar 22, 2016

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.