Search code examples
xcodeswiftipadinterfaceuisplitviewcontroller

Xcode - How to make that master and detail controller shows at the same time?


I read about it and I found enter link description here but when I did it I got an error "fatal error: Array index out of range". I have UISplitViewController, UITabBarController (it is master) and several UIViewControllers. I want to show both the master controller and the detail controller at the same time in portrait orientation like it is looks in horizontal orientation. Please help me.

My interface is looks like enter image description here


Solution

  • I found a simple solution. I made a class for the UISplitViewController then I wrote the following code within it.

    import UIKit
    
    class Split: UISplitViewController, UISplitViewControllerDelegate {
    
        override func viewDidLoad() {
            super.viewDidLoad()
            self.delegate = self
        }
    
        override func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
        }
    
        func splitViewController(svc: UISplitViewController, shouldHideViewController vc: UIViewController, inOrientation orientation: UIInterfaceOrientation) -> Bool {
            return false
        }
    }