I would like obtain a SplitView on my iPad application with my left menu in a portrait orientation such as iPad settings. For now in portrait orientation I have a content view in full screen and I have a button at NavigationBar which includes a popover with my left menu.
8 Answers
This is the magic you need:
This method is in UISplitViewControllerDelegate, available on iOS 5.0
- (BOOL)splitViewController: (UISplitViewController*)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0);
{
return NO;
}

- 1,924
- 20
- 24
-
10This is deprecated in iOS 8. Use "preferredDisplayMode" property set to "UISplitViewControllerDisplayModeAllVisible" for iOS 8 and up. – LightningStryk Dec 30 '14 at 20:59
You should definitely have a look at Matt Gemmell's MGSplitViewController.
MGSplitViewController is an open source replacement for UISplitViewController, with various useful enhancements.

- 81,409
- 55
- 245
- 302

- 40,269
- 27
- 112
- 144
Unfortunately, it's an undocumented method (i.e. private API).
[splitViewController setHidesMasterViewInPortrait:NO];
I think you need to create a custom view controller containing a table view (as the master controller) and another generic subview (as the detail controller) to simulate this.

- 510,854
- 105
- 1,084
- 1,005
-
Undocumented or private API? That's an important question when dealing with Apple ;-) – Paul Lynch Apr 13 '10 at 18:03
-
1
-
3Although, remember: sometimes Apple "undocuments" an option because they want to be the only ones to use that effect. In that case many times they DO turn away apps that just SIMULATE private APIs with changes. I have had that happen when "getting too close to the look and feel" of the darned "edit" function of the "MORE" tab bar controller. They limit the icons you can arrange to 16. I tried to implement something that looked like it...and they turned me down saying it might confuse users if mine functioned close-but-not-the-same as theirs (ie: mine did a bit more.. allowed more than 16). – Jann Apr 14 '10 at 17:37
The easiest way to get the effect you want may be to just not use a UISplitView
. Instead, just create a normal view, put a table view on its left side, your detail view on the right side, and then set the autosizing stuff appropriately so that everything looks right in both portrait and landscape.

- 81,409
- 55
- 245
- 302
As ccwasden stated, shouldHideViewController
is deprecated as of iOS8. In Objective-C, use...
splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeAllVisible;

- 931
- 1
- 10
- 16
Since shouldHideViewController
is deprecated in iOS8, you will need to use this instead (Swift):
splitViewController.preferredDisplayMode = UISplitViewControllerDisplayMode.AllVisible

- 8,438
- 7
- 41
- 48
some people asked me the same question on our blog and I found a solution for that. You will find it at the end of my blog post Your first split view controller | Seaside.
In general, all you have to do is to create a subclass of UISplitViewController
and override the method willAnimateRotationToInterfaceOrientation: duration:
and adjust your master and detail views when the interface orientation will change to portrait mode.
Cheers, Andreas

- 3,817
- 1
- 30
- 36
-
hi anka,i hav seen ur example source code multiple detail view but u didnt implement didselect method in root view ...can u give me a sample for that one also.. – Linux world Sep 24 '10 at 18:36
-
Hi, I added some example code for that at my project MasterDetail. Checkout the git repository at http://github.com/anka/bw_examples/tree/master//MasterDetail/ . Cheers, Andreas – anka Oct 04 '10 at 10:43
-
In Swift:
splitViewController.preferredDisplayMode = .allVisible

- 31,030
- 13
- 103
- 118

- 3,055
- 3
- 30
- 36