Split view controller must be root view controller

自闭症网瘾萝莉.ら 提交于 2019-11-27 08:38:47

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.

xi.lin

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;

The UISplitController CAN BE installed under UITabBarController. I do it. Just use search on this forum - I found at least one good software sample.

Yes Exactly you will have to use RootViewController and it should be inherited from UITableViewController. You may take a look at this tutorial

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!