3
votes

I had a UISplitViewController with the following layout, consisting of a single master and detail view controller.

enter image description here

This worked fine for a basic split view with single views, but I needed to support multiple segues from the UITableViewController (Master View) and not load the detail views until data is passed; or else the app will crash because of optional errors.

I tried by having a set up like so;

enter image description here

This loads a blank ViewController as the detail view when the UISplitViewController loads, and when a row is selected the I have a detail segue to the other view controllers, which should appear as a detail view in the UISplitViewController.

This unfortunately does not work exactly, all the data is passed and loaded without crashes but the detail segues actually load the view controllers within the master view window of the split view not the detail view.

Kind of like this,

enter image description here

How can I have multiple detail view controllers which are not loaded until initiating a segue from the master view UITableViewController and open in the detail window ?

Here's the code from the MasterViewController

override func viewDidLoad() {
    super.viewDidLoad()
    self.splitViewController!.delegate = self;
    self.splitViewController!.preferredDisplayMode = UISplitViewControllerDisplayMode.AllVisible

    self.extendedLayoutIncludesOpaqueBars = true
}


func splitViewController(splitViewController: UISplitViewController, collapseSecondaryViewController secondaryViewController: UIViewController, ontoPrimaryViewController primaryViewController: UIViewController) -> Bool {
    return true
}
1

1 Answers

8
votes

If the segues were already there then try removing the segues from the master view to the other detail views and recreating them using a detail segue.