Recently i had one issue. When in my navigation controller stack (One child controller) :
MainScreen -> ScreenA -> ScreenB -> Screenc
So when in my Screenc i want to hide nav bar and status bar.Its was working fine. But when i come back to my ScreenB my status bar and nav bar are overlap.Not sure why its happend.I search in some google and some SO answers. Then i got that isNavigationBarHidden base is UIViewController while isHidden base is UIView.
Why i hide my both nav bar and status bar with below code :
override var prefersStatusBarHidden: Bool {
return true
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.navigationBar.isHidden = true
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.navigationController?.navigationBar.isHidden = false
}
In my prev screen i got the issues of my status bar and nav bar are got overlapeed.
But when i use this code :
override var prefersStatusBarHidden: Bool {
return true
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.isNavigationBarHidden = true
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
navigationController?.isNavigationBarHidden = false
}
Its work well. There is not overlap in my prev screen. Why its happening. Is there any specific reason behid :
navigationController?.isNavigationBarHidden ( vs )self.navigationController?.navigationBar.isHidden
I am very to the iOS Development. Just want to understand the difference. So that i can learn if i am doing any wrong.
Thanks