9

I need to hide the navigation bar only from the root view controller,

when i try to hide it from the storyboard by disabling the "Show Navigation Bar", it is hidden from all the other view controllers connected to that root view controller.

what can be possible solution ?

MBH
  • 16,271
  • 19
  • 99
  • 149

1 Answers1

27

I solved it with this code:

override func viewWillDisappear(_ animated: Bool) {
    self.navigationController?.setNavigationBarHidden(false, animated: animated);
    super.viewWillDisappear(animated)
}

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    self.navigationController?.setNavigationBarHidden(true, animated: animated)
}
Shamsudheen TK
  • 30,739
  • 9
  • 69
  • 102
MBH
  • 16,271
  • 19
  • 99
  • 149
  • 2
    I found that scrolling back up on a table made the bar appear again. This can be avoided by changing viewWillAppear to navigationController?.navigationBar.hidden = true – Ben Sullivan Apr 27 '16 at 20:46