I have a ViewController called SourceViewController
that is embedded in a NavigationController.
SourceViewController
segues to DestinationViewController
upon UITableViewCell
selection.
I want to hide the navigation bar on SourceViewController
, but display it on DestinationViewController
in order to show the Back button.
So, in SourceViewController
:
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.navigationBar.hidden = true
}
And in DestinationViewController
:
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.navigationBar.hidden = false
}
However, when I tap "Back" in DestinationViewController
to return to SourceViewController
, the navigationBar reappears in SourceViewController
The next 'obvious' step would be to set navigationBar.hidden = false
in viewDidAppear
in SourceViewController
, however this smells for many reasons: mainly DRYness but also when returning to SourceViewController
, there is a delay in hiding the navigationBar
, and it is visible for a split second.
How do I solve this problem?