Navigation bar not showing iOS swift Navigation bar not showing iOS swift ios ios

Navigation bar not showing iOS swift


Navigation Controller is a controller, which has stack of view controllers. So if you have something like this:

NAV -> A -> (segue) B

Even if you'll hide navigation bar you still should be able to make segues. Also can't you just unhide navigation bar in second (B) view controller in viewWillAppear? And in first the same way hide it on viewWillAppear.

edit: Final solution to the problem:Use:

 let controller = storyboard.instantiateViewControllerWithIdentifier("HomeVC") self.navigationController!.pushViewController(controller) 

instead of:

let secondViewController = storyboard.instantiateViewControllerWithIdentifier("HomeVC")presentViewController(secondViewController, animated: false, completion: nil)

Because pushViewController will add secondViewController to its stack. presentViewController was replacing your navigation controller that's why you couldn't see navigation bar.


override func viewWillAppear(_ animated: Bool) {    super.viewWillAppear(animated)    // Hide the navigation bar on the this view controller    self.navigationController?.setNavigationBarHidden(true, animated: animated)}override func viewWillDisappear(_ animated: Bool) {    super.viewWillDisappear(animated)    // Show the navigation bar on other view controllers    self.navigationController?.setNavigationBarHidden(false, animated: animated)}


in viewDidLoad method of the view controller in which you don't want to show navigation bar add the line

navigationController.navigationBarHidden = true

you are presently hiding in all view controllers

Edit: You are presenting view controller instead it should be

self.navigationController!.pushViewController(controller)