UISplitViewController + Split View: hide information at startup

I have a UISplitViewController in an iPad application, and so far I have set the placeholder as the detail view controller at startup, so the right side of the screen did not look blank until the user selects an item.

But now, on iOS 9, when using the 50/50 horizontal Split View (multitasking), the split view controller automatically pushes my placeholder when, of course, I would like it to show the main view, because in this case the placeholder is not needed.

Does anyone know how to avoid this automatic behavior?

Maybe there is a part of the API that does just that, and I skipped this? Something like "selectViewController:" to tell the split view controller to show the main or detail view. Or maybe we can access the internal navigation controller so that we fit in root?

Thanks!

+5
source share
1 answer

You need to implement the UISplitViewControllerDelegate method

- (BOOL)splitViewController:(UISplitViewController *)splitViewController collapseSecondaryViewController:(UIViewController *)secondaryViewController ontoPrimaryViewController:(UIViewController *)primaryViewController 

According to the documentation, this is the return value of the method:

NO to allow the split view controller to try to include the content of the secondary view controllers in the minimized interface or YES to indicate that you do not want the split view controller to do anything with the secondary view controller.

Implementing this delegate method and returning YES should force the split view manager to display the main view controller at startup.

+3
source

All Articles