Search code examples
uitabbarcontrolleruisplitviewcontrollerios8

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?


Solution

  • Just to update the answers above. Since you can't push navigation controllers anymore, you have to push its top view controller instead.

        func splitViewController(splitViewController: UISplitViewController, showDetailViewController vc: UIViewController, sender: AnyObject?) -> Bool {
            if splitViewController.collapsed {
                let tabBarController = splitViewController.viewControllers.first as! UITabBarController
                let selectedNavigationViewController = tabBarController.selectedViewController as! UINavigationController
    
                // Push view controller
                var viewControllerToPush = vc
                if let navController = vc as? UINavigationController {
                    viewControllerToPush = navController.topViewController
                }
                selectedNavigationViewController.pushViewController(viewControllerToPush, animated: true)
    
                return true
            }
    
            return false
        }