UISplitViewController从Master View开始,而不是detailView

时间:2018-03-24 22:38:29

标签: ios swift uinavigationcontroller uisplitviewcontroller

应用程序从detailViewController开始,而不是MasterViewController。 如何在iPhone中解决这个问题? (它是一个通用的应用程序,并且在iPad上运行时不需要更改)

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

    if segue.identifier == "embedseg" {

        guard let splitViewController = segue.destination as? UISplitViewController,
        let leftNavController = splitViewController.viewControllers.first as? UINavigationController,
        let masterViewController = leftNavController.topViewController as? MasterViewController,
        let rightNavController = splitViewController.viewControllers.last as? UINavigationController,
        let detailViewController = rightNavController.topViewController as? DetailViewController

        else { fatalError() }

        let firstMonster = masterViewController.monsters.first
        detailViewController.monster = firstmonster

        masterViewController.delegate = detailViewController

        detailViewController.navigationItem.leftItemsSupplementBackButton = true
        detailViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem


    }
}

0 个答案:

没有答案