简体   繁体   中英

UISplitView using Storyboard in Universal iOS app

I am using UISplitView in my universal iOS application and I have one storyboard only. I am able to implement all functionality except few things,

In iPad I want master view to be visible always hence I used the delegate,

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

But still the master view is hiding in Portrait mode. Also in iPhone the application launches with DetailView with navigation back button. I want the iPhone application to display MasterView first. I have gone through several samples like this , or this , but nothing solved my issue.

I am using Objective C not Swift.

Have a look at the documentation for UISplitViewControllerDelegate

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

has been deprecated in iOS8, you have to set the preferredDisplayMode instead:

controller.preferredDisplayMode = UISplitViewControllerDisplayModeAllVisible;

As for the iPhone app displaying the detail view controller instead of the master, implement the UISplitViewControllerDelegate method:

- (BOOL)splitViewController:(UISplitViewController *)splitViewController collapseSecondaryViewController:(UIViewController *)secondaryViewController ontoPrimaryViewController:(UIViewController *)primaryViewController {
    return YES;
}

You may set this property by user-runtime variables like this:

Key Path                Type      Value
preferredDisplayMode    Number      2 

Here are the values for preferred display mode

case automatic = 0
case primaryHidden = 1
case allVisible = 2
case primaryOverlay = 3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM