2
votes

iOS 10/Swift:

Using SplitViewController on an iPhone the user sees the detail view when the app loads (whether in portrait or landscape both have compact width). How can you change this to load the master view on startup?

Note that when you load in a Regular Width view (ie: iPhone 6s Plus landscape) we want the Split View to continue to be shown (and not master).

2

2 Answers

3
votes

You should use method

func splitViewController(_ splitViewController: UISplitViewController, collapseSecondary secondaryViewController: UIViewController, onto primaryViewController: UIViewController) -> Bool

which provided by UISplitViewControllerDelegate

-1
votes

You can define a custom UISplitViewController and assign it to your split view in the storyboard:

import UIKit

class MainSplitViewController: UISplitViewController, UISplitViewControllerDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.delegate = self
    }

    func splitViewController(_ splitViewController: UISplitViewController, collapseSecondary secondaryViewController: UIViewController, onto primaryViewController: UIViewController) -> Bool {
        return true
    }
}