1

So, I'm programming a universal application, and with iOS 8, it seems easiest to create split views to ensure that everything properly appears on iPhones and iPads. The dominant UI component in my app is a tab bar.

One of my tabs is a tableview that acts as a menu. I want to push a split view controller from didSelectRowAtIndexPath like so:

[self.navigationController pushViewController:ytSplitViewController animated:YES];

This returns an error: Split View Controllers cannot be pushed to a Navigation Controller

I can modally present the view controller, but this hides my tab bar and makes my interface more convoluted (an undesirable result)

[self.navigationController presentViewController:ytSplitViewController animated:YES completion:nil];

Is there a workaround that I can employ to present my SplitViewController within my UI paradigm? More clearly, can I essentially push my split view controller using a different method?

In case it's relevant, this is how I create my split view:

YTTableViewController *ytTableViewController = [YTTableViewController new];
UINavigationController *ytNavigationController = [[UINavigationController alloc] initWithRootViewController:ytTableViewController];
YTDetailViewController *ytDetailViewController = [YTDetailViewController new];
UINavigationController *ytDetailNavigationController = [[UINavigationController alloc] initWithRootViewController:ytDetailViewController];
NSArray *ytViewArray = [NSArray arrayWithObjects:ytNavigationController, ytDetailNavigationController, nil];
UISplitViewController *ytSplitViewController = [UISplitViewController new];
ytSplitViewController.viewControllers = ytViewArray;
ytSplitViewController.delegate = ytDetailViewController;

1 Answer 1

6

Split view controllers are meant to be presented as root objects, not pushed in the hierarchy.

Of course, you can always trick it, by using view controller containment. Create a UIViewController subclass, add the split view controller as a child controller, and push the parent controller. This should work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.