Cathy Oun
Cathy Oun

Reputation: 315

Adding a navigation controller programmatically for the second VC

In my storyboard, I have setup a navigation controller points to my MainVC, and it works just fine. And now, I'm trying to add another view called "HelpVC", and I created one in the storyboard. It automatically shows the navigation bar on the top. (MainVC segues to HelpVC)

However, I did everything else in code. I had initWithView in the HelpVC which draws out the interface, BUT the navigation bar does not show up, so I can't go back to that previous view controller.

How do I make sure that the navigation bar shows up and works just like other view controllers? (segue back to the last view?)

Upvotes: 1

Views: 293

Answers (1)

ksa_coder
ksa_coder

Reputation: 1413

It is not very clear from the post, but as I understood, you may want to try:

override func viewWillAppear(_ animated: Bool){
  super.viewWillAppear(animated)
  self.navigationController?.isNavigationBarHidden = false
}

Upvotes: 1

Related Questions