Seth Seth - 1 month ago 10
Swift Question

Switch Between Storyboards Using Swift

I have a storyboard that is getting too large in my Xcode project and slowing down my computer. How do I programmatically (or manually using storyboarding) go from one of my views in the current storyboard using a button to advance to a view on the new storyboard?

Semi-new with Xcode so the simpler the better. Thanks!

Answer

You can do it programatically this way:

let storyboard = UIStoryboard(name: "myStoryboardName", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("nextViewController") as UIViewController
presentViewController(vc, animated: true, completion: nil) 

In Sort you can do it like:

presentViewController( UIStoryboard(name: "myStoryboardName", bundle: nil).instantiateViewControllerWithIdentifier("nextViewController") as UIViewController, animated: true, completion: nil)

And don't forget to give ID to your nextViewController.

For more Info refer THIS.

Comments