ios How To Segue From Single View To Split View Controller

陌路散爱 提交于 2019-12-03 23:42:39

Use a container view in a normal View Controller, covering up the whole viewing area, and that container view has an embed segue to the Split View Controller

Overwrite the UISplitViewController and put this in the viewDidLoad if you need to communicate between them:

YourLeftVC *masterViewController = (YourLeftVC *) [[self.viewControllers objectAtIndex:0] topViewController];
YourRightVC *detailViewController = [self.viewControllers objectAtIndex:1];

masterViewController.delegate = detailViewController;
miOS

Instead of presenting splitviewcontroller try to set as rootviewcontroller.

self.view.window.rootViewController = splitViewController;

As per apples documentation https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/ViewControllerCatalog/Chapters/SplitViewControllers.html

A split view controller must always be the root of any interface you create. you must always install the view from a UISplitViewController object as the root view of your application’s window.

What you can do here is create a custom splitview.

Worst case scenario you could create a second UIViewController to make the push, and on it a container that have the UISplitViewController as root.

Set your segue to modal and not push, that should do it.

EDIT

Actually that doesn't work. What you can try is putting your splitView in another storyboard, and in your buttonClicked: method present it in code :

In SigleView.m :

- (IBAction)buttonClicked:
{
    SplitViewController *splitVC = [[UIStoryboard storyboardWithName:@"SplitStoryBoard" bundle:nil] instantiateViewController];
    [self presentViewController:splitVC animated:YES completion:nil];
}

EDIT2

What's written before isn't working either. I really wonder if you CAN present a splitViewController (i.e not make it your rootViewController).

But there's someting you can do :

Set your splitView as the rootView of your app, present modally your singleView at launch, and whenever you want just dismiss it to let the splitView have control. Will have the same effect than having your singleView presenting the splitView.

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