Search code examples
iosswiftipaduisplitviewcontrollermultitasking

ipad air 2 multitasking replaces the master view on details view


When I'm doing multitasking and trying to resize the split view after I did a navigation on my master view, then the master view it clones on details view and I can't figure out how to solve it.

enter image description here

Any ideas what I did wrong?


Solution

  • I found a solution applying a method delegate from UISplitViewControllerDelegate

      func splitViewController(splitViewController: UISplitViewController, separateSecondaryViewControllerFromPrimaryViewController primaryViewController: UIViewController) -> UIViewController? {
        let primaryNavController = primaryViewController as! UINavigationController
        primaryNavController.popToRootViewControllerAnimated(false)
    
        let detailNavigationController = storyboard!.instantiateViewControllerWithIdentifier("NavigationController") as! UINavigationController
        let detailViewController = detailNavigationController.viewControllers.first as! DetailViewController
    
        // Here update your detail view controller
    
        return detailNavigationController
    }