Split view controller must be root view controller Split view controller must be root view controller ios ios

Split view controller must be root view controller


From the Apple iPad Programming Guide:

The split view controller’s view should always be installed as the root view of your application window. You should never present a split view inside of a navigation or tab bar interface.

So yes, you cannot present a split view outside of your main application window (that includes modally).

EDIT

The link to the docs above no longer discusses this topic. Relevant discussion can now be found at Apple's View Controller Catalog for iOS, which states the following:

A split view controller must always be the root of any interface you create. In other words, you must always install the view from a UISplitViewController object as the root view of your application’s window. [...] Split view controllers cannot be presented modally.


I got the same problem with the same error when I tried to segue from a regular content view controller (ie. no problem segueing from a tab controller or a nav controller).

Fortunately I found a way to circumvent this by inserting a nav controller between the VC and the split view controller. In other word, segue from the VC to a nav controller, then draw a relationship connection between the nav controller and the split view controller. In this way, instantiating a split view still requires no coding.


Of course u can use UISplitViewController without using it as root view controller.In my project, I use it like this:

  1. Show my own viewcontroller in modal method:
[self presentModalViewController:mainViewController animated:YES];
  1. In the mainViewController, I have
UISplitViewController *splitViewController;

and in - (void)viewDidLoad, set the splitViewController.view to mainViewController.view

splitViewController.viewControllers = [NSArray arrayWithObjects:masterNavigationController, detailNavigationController, nil];self.view = splitViewController.view;