I\'m doing a universal App using size classes and I\'m trying to use a SplitView with a TabBarController in the Master/Primary View. Before adding the splitView all worked f
So, I found something that works, even if is not the standard behaviour:
- (void)collapseSecondaryViewController:(UIViewController *)secondaryViewController forSplitViewController:(UISplitViewController *)splitViewController
{
[self.selectedViewController.navigationController collapseSecondaryViewController:secondaryViewController forSplitViewController:splitViewController];
}
That is equivalent to return always YES
in the splitViewController:collapseSecondaryViewController:ontoPrimaryViewController:
delegate method. Like this you always discard the secondary controller.
Hope this can help someone.
Try this snippet and told us your results. This snippet get from a website outside stackOverflow (Craig Marvelley)
#pragma mark - Split view
// Update secondaryview with the right screen
- (UIViewController *)splitViewController:(UISplitViewController *)splitViewController separateSecondaryViewControllerFromPrimaryViewController:(UIViewController *)primaryViewController {
int tryIt = 0;
if ((IS_IPHONE_6_PLUS) && (isLandscape)) {
if ([primaryViewController isKindOfClass:[UINavigationController class]]) {
for (UIViewController *controller in [(UINavigationController *)primaryViewController viewControllers]) {
tryIt = tryIt + 1;
if ([controller isKindOfClass:[UINavigationController class]] && ([[(UINavigationController *)controller visibleViewController] isKindOfClass:[yourPosibleScreen01 class]] || [[(UINavigationController *)controller visibleViewController] isKindOfClass:[yourPosibleScreen02 class]]) ) {
return controller;
}
// Sublevel where yo are to select the right screen. You must try with a number depends of how many internal hierarchy. But I believe you need number 2 but try it :)
if (tryIt > 2) {
return controller;
}
}
}
// Update detail screen
UIViewController *toViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"YourScreenToShow"];
return toViewController;
}
return nil;
}
- (BOOL)splitViewController:(UISplitViewController *)splitViewController collapseSecondaryViewController:(UIViewController *)secondaryViewController ontoPrimaryViewController:(UIViewController *)primaryViewController {
return NO;
}
#pragma mark - Split view