Open UISplitViewController to Master View rather than Detail

前端 未结 7 1175
北海茫月
北海茫月 2020-12-04 13:14

I have a split-view interface with a target iPhone 6 application. On the first launch of the application, it opens to the Detail View; I would like it to open to the Master

7条回答
  •  既然无缘
    2020-12-04 13:51

    Or just inherit from UISplitViewController and use this new class in the storyboard (based on SwiftArchitect's answer):

    class MasterShowingSplitViewController :UISplitViewController, UISplitViewControllerDelegate {
        override func viewDidLoad() {
            super.viewDidLoad()
    
            self.delegate = self
            self.preferredDisplayMode = .allVisible
        }
    
        func splitViewController(
            _ splitViewController: UISplitViewController,
            collapseSecondary secondaryViewController: UIViewController,
            onto primaryViewController: UIViewController) -> Bool {
            // Return true to prevent UIKit from applying its default behavior
            return true
        }
    }
    

提交回复
热议问题