I have a UISplitViewController in which MasterViewController and DetailViewController has its own navigation controller.
This is my storyboard:

When MasterViewController and DetailViewController are both visible (iPhone 6+ Landscape and iPad):
DetailViewController uses Detail Navigation Controller. Everything is perfect in here.
When only DetailViewController is visible (iPhone 6+ Portrait and all other iPhones both Landscape and Portrait):
DetailViewController still uses Detail Navigation Controller (self.navigationController returns Detail Navigation Controller). But on top, Master Navigation Controller's navigation bar is visible, instead of Detail Navigation Controller's navigation bar.
I want to use same navigation bar for DetailViewController for every device size in both portrait and landscape mode. (Styling for master's navigation bar and detail's navigation bar is different.)
Is there a way to do this without declaring a hacky computed property named currentlyVisibleNavigationController or keeping references between ViewControllers?
To get the current UINavigationBar object of the detail controller in a UISplitViewController context, you can try this:
let navigationBar = navigationController?.navigationController?.navigationBar ?? navigationController?.navigationBar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With