How to create a segue from UIViewController to a UISplitViewController

跟風遠走 提交于 2019-12-02 01:02:39

You can't do that. A split view controller has to be the root view controller of the window.

From the "View Controller Catalog for iOS" : "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."

After Edit: I just tried the code method that I mentioned in my comment, and it worked. So, in your storyboard, you can set up the controllers the way you want, just don't make any connection between your first controller and the split view controller. Then in code switch to it with this code:

-(IBAction)switchToSplit:(id)sender {
    UISplitViewController *split = [self.storyboard instantiateViewControllerWithIdentifier:@"Split"];
    self.view.window.rootViewController = split;
}
Jan Bühler

While the split view controller has to be the root view controller of its window, an app can have multiple windows. Sadly, this concept is hardly known by developers and works only programatically and not via Interface builder (to my knowledge). I believe the following answer can help with your issue:

How to use a UISplitViewController as a Modal View Controller?

You might want to use a UITabBarViewController. Although Apple doesn't require UISplitViewController to be the root view controller they encourage it in most cases unless you're using it inside of a UITabBarViewController like Apple's Podcast app.

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