Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UISplitViewController: How force to show master popover in app launch? (portrait)

In an iPad App i'm using the UISplitViewController. I need to force to show the master popover when the app launch in portrait mode.

Now I'm using this code and it works well on iOS 5.0.

if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) {    if ([[[AppDelegate sharedAppDelegate] splitViewController] respondsToSelector:[[[AppDelegate sharedAppDelegate] btnMenu] action]]) {       [[[AppDelegate sharedAppDelegate] splitViewController] performSelector:[[[AppDelegate sharedAppDelegate] btnMenu] action]];    }             } 

But in iOS 5.1 (with the new type of master popover) the behaviour seems to be random. Sometimes the popover shows in fullscreen and sometimes works well.

Some suggestion for 5.1?

like image 964
alejandromp Avatar asked May 03 '12 07:05

alejandromp


1 Answers

No suggestion here for 5.1, but one for 8.0:

Now with iOS8, there are a bunch of new methods for UISplitViewController configuration.

In your case, juste set the right value in preferredDisplayMode, for example in the masterViewController viewDidLoad.

Objective-C:

- (void)viewDidLoad {     // configuring splitviewcontroller     self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeAllVisible;      //.... } 

Swift:

    override func viewDidLoad() {         self.splitViewController?.preferredDisplayMode = UISplitViewControllerDisplayMode.AllVisible     } 

But it's of course iOS8 only.

like image 84
Martin Avatar answered Sep 20 '22 22:09

Martin