if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
UISplitViewController *splitViewController = (UISplitViewController *)[[tabBarController viewControllers] firstObject];
UINavigationController *navigationController = [[splitViewController viewControllers] lastObject];
splitViewController.delegate = (id)navigationController.topViewController;
}
This is my current code to check if the device is an iPad. If it is, it should set the tabbarcontroller's first object's last object's only view controller. The storyboard goes as following:
Tabbarcontroller[0]>Splitviewcontroller[1]>Navigationcontroller[0]>delegate(?)
I still have no idea what the delegate does, but upon checking apple's template code for a split view controller, I think it uses the delegate to notify the detail view controller to update content. The line I'm crashing is [splitViewController viewControllers]
According to Apple Guides UISplitViewController
should be the root view controller i. e. it cannot be inserted into UITabBarController
as child controller:
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.
From "View Controller Catalog for iOS" User Guide