Vin
Vin

Reputation: 10548

Forcing an iPad app to show splitView even in Portrait orientation(Like the Settings iPad app)

I am trying to develop a splitView based iPad app, that displays the split interface in every orientation. I have tried subclassing the UISplitViewController class as given in this tutorial, but it doesn't work. I tried creating a category to set _hidesMasterViewInPortrait = (hidden) ? 0 : 1;, as suggested in one of the comments in the above blog, but nothing worked.

Can anyone help me to find a way out of this, without using any third party frameworks or classes?

Upvotes: 4

Views: 7649

Answers (9)

chasew
chasew

Reputation: 8828

In iOS8 (Swift), use this:

splitViewController.preferredDisplayMode = UISplitViewControllerDisplayMode.AllVisible

Upvotes: 14

Vinod Joshi
Vinod Joshi

Reputation: 7862

you just need to add this delegate method to your detail view manager

    - (BOOL)splitViewController:(UISplitViewController *)svc 
       shouldHideViewController:(UIViewController *)vc 
                  inOrientation:(UIInterfaceOrientation)orientation
    {
        // Hide split view in portrait mode
        //return UIInterfaceOrientationIsPortrait(orientation);

        // Show Split view in portrait mode
        return NO;
    }

//vKj

Upvotes: 0

Aaron Bratcher
Aaron Bratcher

Reputation: 6471

In the viewController class that implements the UISplitViewControllerDelegate Protocol (usually the DetailViewController), add the following code.

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

According to the Docs, this has been available since iOS 5.

To see it in action:
-open Xcode.
-Create a new Master/Detail app.
-Add the above code to the DetailViewController
-Run in the iPad simulator.

In your own project you'll want to add the following line to the viewDidLoad method of the detailViewController.

self.splitViewController.delegate = self;

Upvotes: 13

ader
ader

Reputation: 5393

You cannot have Apple' splitViewController behave like that (and get in the app store). You would need to write your own container view controller. See Apple' docs

Upvotes: 0

Son Nguyen
Son Nguyen

Reputation: 3491

you can subclass UISplitViewController, then overwrite following method:

 - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval) duration

Upvotes: 1

ichATios
ichATios

Reputation: 9

hello my first post and i hope to help:

here is the way it works

[splitViewController setHidesMasterViewInPortrait:NO];

Upvotes: 0

matt
matt

Reputation: 535889

What you are describing sounds like Apple's Settings app (on iPad). My intuition would be that this is not a UISplitView. It's just a view containing two table views. Fix the layout manually when the device rotates. In other words, if you don't want what a UISplitView does, then you don't a UISplitView at all.

EDIT 12/19/2011: In iOS 5 the problem is basically solved, since you can now define your own container view controller, plus you can prevent the dismissal of the left view in a split view.

Upvotes: 3

Andriy
Andriy

Reputation: 1894

I'm not sure that it is possible with standard SplitViewController, but you can use custom one from

https://github.com/mattgemmell/MGSplitViewController

Upvotes: 2

VdesmedT
VdesmedT

Reputation: 9113

I never achieved to force the SPlitViewController to do that but since you need to create controllers for both parts, you can just reuse those controllers to display the content the way you want it.

Upvotes: 1

Related Questions