Question

I have 5 views in my app and I'm appDelegate by setting them in the following way:

    UITabBarController *tabBarController = [[UITabBarController alloc] init];
        tabBarController.viewControllers = [NSArray arrayWithObjects:navigationcontroller1, navigationcontroller7, navigationcontroller5, navigationcontroller4, navigationcontroller6, navigationcontroller2, nil];

self.window.rootViewController = tabBarController;

All of them come with a NavigationController and tabbarcontroller, But I needed to split the screen into two parts, in this case the screen would be divided would be navigationcontroller2, as you can see below:

VendaViewController *venda_viewcontroller = [[VendaViewController alloc] init];
    UINavigationController *navigationcontroller2 = [[UINavigationController alloc] init];
    [navigationcontroller2 pushViewController:venda_viewcontroller animated:YES];

Hence I tried the following way:

VendaViewController *venda_viewcontroller = [[VendaViewController alloc] init];
VendaDetailViewController *vendaDetail_viewcontroller = [[VendaDetailViewController alloc] init];

UISplitViewController *splitVC = [[UISplitViewController alloc] init];

[splitVC setViewControllers:[NSArray arrayWithObjects:venda_viewcontroller,vendaDetail_viewcontroller,nil]];

    UINavigationController *navigationcontroller2 = [[UINavigationController alloc] init];
    [navigationcontroller2 pushViewController:splitVC animated:YES];

But not work in this code, but in documentation of UISplitViewController is writing the following message:

"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."

So...If I like to put a splitViewController in my view controller, I'll have to put splitViewController in all of my views controllers? Or have another solution to this?

Was it helpful?

Solution

You can use a UISplitViewController only as the root view controller of your app. In your case you can implement your custom container view controller with functionality similar to the split (two subview controller inside the main). Follow this link for details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top