"The application tried to introduce split view modally controllers."

I'm still trying to find a solution to what is theoretically a very simple task and comes from the UIViewController to the Split View controller. (Why an apple made it so difficult).

I am in the stage where I now put the SplitViewController in my own storyboard. And when the user selects a button on one UIView controller, I call the following code:

UISplitViewController *splitVC = [[UIStoryboard storyboardWithName:@"SplitStoryBoard" bundle:nil] instantiateViewController]; [self presentViewController:splitVC animated:YES completion:nil]; 

So, I want to load the storyboard using the splitview controller. But it also crashes with "Application trying to present Split View modally controllers"

I did not specify any "modal" actions in the code.

Is there any solution how to do this?

+6
source share
5 answers

UISplitViewController must always be the root view controller and cannot be represented modally. See Apple docs for more details :

The shared view controller must always be the root of any interface that you create. In other words, you should always set the view from the UISplitViewController object as the root view of your application window. Then the panels of your interface with a split view can contain navigation controllers, tab bar controllers or any other kind of controller you need to implement your interface. Split representation controllers cannot be represented modally.

+2
source

You can use splitViewController as a view for TabViewController, however, splitViewController cannot be a modal controller in the traditional sense. To navigate to SplitViewController from a UIViewController, use the following code:

 - (IBAction)setupTapped:(id)sender { static NSString *tabViewControllerIdentifier = @"SetupViewController"; UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:tabViewControllerIdentifier]; AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate]; UIViewController *currentController = app.window.rootViewController; app.window.rootViewController = controller; app.window.rootViewController = currentController; [UIView transitionWithView:self.navigationController.view.window duration:0.75 options:UIViewAnimationOptionTransitionFlipFromRight animations:^{ app.window.rootViewController = controller; } completion:nil]; } 

This will be the transition between controllers. You can change the type of animation to suit your needs. This is specified by the options parameter; UIViewAnimationOptionTransitionFlipFromRight is currently displayed.

+2
source

If you created a UISplitViewController in a storyboard and when adding a main view before a split view, you can use performSegueWithIdentifier to start the segment between the main view and the split view. To fix a header error, you need to override one method in the UISplitViewController

 // Swift override func awakeFromNib() { let app = UIApplication.sharedApplication().delegate as AppDelegate let currentController = app.window!.rootViewController; app.window!.rootViewController = self; } 
0
source

Yes, it is possible to switch from UIView to UISplitView. You must use a custom segment.

Read this link (translate it from Japanese)

UIViewController for UISplitViewController

0
source

This question is pretty old. However, I got this using the below code in my application, and I think this is the best solution.

 [self addChildViewController:<# Your Split VC #>]; [<# Your Split VC #>.view willMoveToSuperview:self.view]; <# Your Split VC #>.view.frame = self.view.frame; [self.view addSubview:<# Your Split VC #>.view]; [<# Your Split VC #>.view didMoveToSuperview]; 

The idea is to take a view controller (parent) and add a child view controller as its child. Run the segue model for the parent, as for any other controller.

Well, I'm not sure, but SplitViewController is much better from iOS8, and should be conveniently used in a place other than the root view controller.

Hooray!

0
source

Source: https://habr.com/ru/post/959161/


All Articles