Difference between revisions of "Swift:Navigation between storyboards"
From Hawk Wiki
(Created page with "===Navigate to Storyboard ID=== <pre class="brush:swift"> var vc = storyboard.instantiateViewControllerWithIdentifier("loginViewController") as UIViewController window?.rootVi...") |
(No difference)
|
Latest revision as of 04:08, 23 March 2015
var vc = storyboard.instantiateViewControllerWithIdentifier("loginViewController") as UIViewController window?.rootViewController = vc
First, drag a segue in storyboard and give it an identifier, then in the button action (or any action you like), do:
self.performSegueWithIdentifier("loginSegue", sender: self)
Sometimes, you want to access the UIViewController from a navigation controller
var vc = storyboard?.instantiateViewControllerWithIdentifier("navigationID") as UINavigationController var v = vc.viewControllers[0] as ViewController // [0] represents the first level UIViewController under NavigationController