UISplitViewController display master view above detail in portrait orientation

不羁的心 提交于 2019-12-04 05:48:45
lewiguez

Edit: It's not a duplicate. Answer discovered in the comments. The solution is to use preferredDisplayMode on UISplitViewController and setting it to UISplitViewControllerDisplayModePrimaryOverlay

Left the original answer for context to the comments and posterity.


Original Answer

This is a duplicate of this: UISplitViewController in portrait on iPhone shows detail VC instead of master

For reference, the solution in that case was to have the view controller that implements UISplitViewControllerDelegate use the following code:

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

    if ([secondaryViewController isKindOfClass:[UINavigationController class]]
        && [[(UINavigationController *)secondaryViewController topViewController] isKindOfClass:[DetailViewController class]]
        && ([(DetailViewController *)[(UINavigationController *)secondaryViewController topViewController] detailItem] == nil)) {

        // Return YES to indicate that we have handled the collapse by doing nothing; the secondary controller will be discarded.
        return YES;

    } else {

        return NO;

    }
}
Reefwing

Alternatively you can use:

    - (BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController: (UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation {

    //  Force master view to show in portrait and landscape

    return NO;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!