How to Navigate from Initial UIViewController to UISplitViewController in Swift

心不动则不痛 提交于 2019-12-11 03:56:09

问题


I am showing my details in UISplitViewController in AllVisible mode. But, before that, loginViewController is there. User should login, then it will navigate UISplitViewController. I don't know how to navigate to that viewController. I am not using any UINavigationController inside my app. I have tried something, but failure. I used following code:

Code:

//ATTEMPT 1:
self.performSegueWithIdentifier("split", sender: self)

//ATTEMPT 2:
let leftVC = atlMasterVC()
let detailVC = atlDetailVC()
let splitViewController = splitVC()
splitViewController.viewControllers = [leftVC,detailVC]

//ATTEMPT 3
self.presentViewController(splitViewController, animated: true, completion: nil)
let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("split") as! splitVC
self.presentViewController(nextViewController, animated:true, completion:nil)

If I am any wrong, kindly guide me.


回答1:


You are doing something wrong. I have no problem in my code and it goes to split view if the password is OK. Take a look at this:

Story Board: Login -> Split -> (Master, Detail)

Login Has A Button, A Switch And A Segue Between Itself And Split View Controller (identifier: 'showsplit')

LoginViewController Class:

class LoginViewController: UIViewController {
    @IBOutlet weak var pass: UISwitch!

    @IBAction func btn(sender: AnyObject) {
        if pass.on {
            performSegueWithIdentifier("showsplit", sender: self)
        }
    }
}


来源:https://stackoverflow.com/questions/31307858/how-to-navigate-from-initial-uiviewcontroller-to-uisplitviewcontroller-in-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!