Мой профиль...

Search This Blog

Friday, December 9, 2016

Swift: programmatically switch ViewController

To switch between ViewController in Swift, you can use the following code:
@IBAction func nextButtonTapped(sender: AnyObject) {
    var nextView: TheNextViewController = self.storyboard?.instantiateViewControllerWithIdentifier("TheNextViewController") as! TheNextViewController
    let appdelegate = UIApplication.sharedApplication().delegate as! AppDelegate
    appdelegate.window!.rootViewController = nextView
}

No comments:

Релевантные посты...

Related Posts with Thumbnails