I have NavigationController that handles navigation through my app. According to my design, the very first view should have no visible NavigationBar. All the others after, will.
In this FirstView, I'm using this so far to hide the NavBar, inside the ViewDidLoad:
self.navigationController?.isNavigationBarHidden = true
From this FirstView I can access other Views. In these other views I show the NavBar using:
self.navigationController?.isNavigationBarHidden = false
My problem is that:
How Can I Prevent this ?
Thank you!
Move that code to viewWillAppear()
instead of viewDidLoad()
.
viewDidLoad()
is only called once per instantiated view controller, whereas viewWillAppear()
is called whenever the view controller is about to be presented on screen.
You can read more about the view controller lifecycle here.