Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
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