To set the scene I have:
I've attached a very simple sample project showing the issue.
Run it in the iPad 5.1 Sim, observe each tab. One shows the shared detail view, one fails.
NSLog debugging reports that the second split view has a NULL detail view controller:
2012-04-28 07:21:55.451 svcTest[14597:f803] tabBarController viewControllers = ( "UISplitViewController: 0x6a36100", "UISplitViewController: 0x6a39ab0" ) 2012-04-28 07:21:55.455 svcTest[14597:f803] svcA.viewControllers = ( "UINavigationController: 0x6a36250", "UIViewController: 0x6a38720" ) 2012-04-28 07:21:55.457 svcTest[14597:f803] svcB.viewControllers = ( "UINavigationController: 0x6a39cc0" )
When you click the second tab you get this error:
2012-04-28 07:22:58.457 svcTest[14597:f803] Splitview controller is expected to have a detail children before its used! 2012-04-28 07:22:58.459 svcTest[14597:f803] Split view controller should have its children set before layout!
Looking at the storyboard I have already set the detail views so this really confuses me.
Any help getting this 'shared' view to show up on each tab is much appreciated.
Thanks!
I received the same warning when specifying more than two viewControllers for the splitViewController as shown below:
self.splitViewController.viewControllers = @[masterNavigationController, detailNavigationController, subViewController];
When i removed 'subViewController' from the array the warning disappeared.
After reading apple's documentation on adding / removing subviews it mentions the following:
The array in this property must contain exactly two view controllers. The view controllers are presented left-to-right in the split view interface when it is in a landscape orientation. Thus, the view controller at index 0 is displayed on the left side and the view controller at index 1 is displayed on the right side of the interface.
You can check out the link to UISplitViewController Class Reference for more information.
The Problem is in placement of some lines located in App Delegate's -applicationdidFinishLaunchingWithOptions:
Here, the split view controller delegate is set before the viewControllers. This seems to be the source of the problem and if you reverse the two lines as shown below the warning message disappears:
Use this Code instead :
self.splitViewController = [[UISplitViewController alloc] init];
self.splitViewController.viewControllers = [NSArray
arrayWithObjects:masterNavigationController,
detailNavigationController, nil];
self.splitViewController.delegate = detailViewController;
For detailed explanation, you can take a look at : Splitview Controller Is Expected to Have a Master View Controller
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With