Welcome to the Treehouse Community
Looking to learn something new?
How does Navigation Controller work with Split View Controller under the hood?
I have difficulty understanding the behavior on iPhone(Portrait).
No navigation controller for both master and detail, it shows master in the beginning. If master is embedded in a navigation controller, then it shows detail first, yet you can go back to master through navigation bar.
Question: Master is the only one embedded in navigation controller, isn't it supposed to be the only controller on navigation stack? How does detail get a navigation bar and pop-off effect like it is on that stack as well?
If I go the other way around, put a navigation controller in Detail instead of Master. Not surprisingly, it shows Master first this time. Yet Master does not get the same treatment, it does not get a navigation bar, and there is no way you can go back from it to Detail.
Question: What causes this different "treatment"?
Steven Deutsch21,046 Points
Hey Yaxin Yuan,
For portrait mode on the iPhone the UISplitViewController will display the detail view first when the app is displayed on screen. If you want to change which view is displayed first, you can use the UISplitViewControllerDelegate to do so.
If you return true from the UISplitViewControllerDelegate method, splitViewController(_:collapseSecondaryViewController:ontoPrimaryViewController:), your master view, or root view in the navigation controller in your case, will be displayed first.
For more information, check the UISplitViewController documentation: UISplitViewController
UISplitViewControllerDelegate documentation: UISplitViewControllerDelegate