Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS8 TabbarController inside a UISplitviewController Master

I've tried to expand the default Apple MasterDetail Template by adding a UITabbarController in front of the UINavigationController of the MasterView, so there is a structure like this:

UISplitViewController (Master) > UITabbarController > UINavigationController > UITableViewController

But if I run the App, after changing application(didFinishLaunchingWithOptions) to use the correct ViewController, and try to perform the ShowDetails Segue the DetailsView ist presented Modally on the iPhone. On the other side the iPad Version is working as expected. What am I forgot to do? Or how can I fix it?

like image 558
ItsTCalling Avatar asked Aug 30 '14 09:08

ItsTCalling


1 Answers

I figured out how to put the detail on to the master's UINavigationController instead of presenting it modally over the UITabBarController.

Using the UISplitViewControllerDelegate method

- splitViewController:showDetailViewController:sender:

In case the UISplitViewController is collapsed get the masters navigation controller and push the detail view onto this navigation controller:

- (BOOL)splitViewController:(UISplitViewController *)splitViewController
   showDetailViewController:(UIViewController *)vc
                     sender:(id)sender {
    NSLog(@"UISplitViewController collapsed: %d", splitViewController.collapsed);

    // TODO: add introspection
    if (splitViewController.collapsed) {
        UITabBarController *master = (UITabBarController *) splitViewController.viewControllers[0];
        UINavigationController *masterNavigationController = (UINavigationController *)master.selectedViewController;

        // push detail view on the navigation controller
        [masterNavigationController pushViewController:vc animated:YES];

        return YES;
    }

    return NO;
}
like image 128
Peter Oettl Avatar answered Sep 29 '22 13:09

Peter Oettl