1

The project I am working on currently has multiple storyboards. we are programatically moving from the first storyboard to the next using the following code:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
            let vc = storyboard.instantiateViewController(withIdentifier: "DiscoverViewController") as UIViewController
            self.present(vc, animated: true, completion: nil)

the storyboard it is moving to has the Storyboard Entry Point pointed at the Navigation Controller of the view controller that is being instantiated and presented above.

The problem is that when the the page is displayed the navigation bar doesn't appear. It appears on the storyboard view, and before we separated the storyboards we weren't having this issue.

Is there an issue with the way I am going from one storyboard to the other? Do I need to present the navigation controller rather than the view controller?

thanks!

Nickknack
  • 827
  • 4
  • 12
  • 26
  • Your second controller isn't a NavigationController. So you are presenting a ViewController and "hiding" the Navigation bar. You need to push your new controller (not present it) to keep the Navigation Bar. – Vertig0 Mar 26 '17 at 23:17

1 Answers1

0

This is because you're presenting the view controller, when instead you probably want to push it onto the navigation stack.

This answer shows what you need to do. Here is the code, adapted for your example:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "DiscoverViewController") as UIViewController
self.navigationController?.pushViewController(vc, animated: true)
Community
  • 1
  • 1
Forest Kunecke
  • 2,160
  • 15
  • 32