Switch Between Storyboards Using Swift
37,256
Solution 1
You can do it programatically this way:
Swift 3+
let storyboard = UIStoryboard(name: "StoryboardName", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "ViewControllerID") as UIViewController
present(vc, animated: true, completion: nil)
Older
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.
Solution 2
0 Lines of Code
Using Interface Builder
- Add a Storyboard Reference to the source storyboard
- Control-Drag from the
UIButton
to that Storyboard Reference
- In the Attributes inspector of the Storyboard Reference placeholder, specify the destination Storyboard and optionally the destination Reference ID of the target
UIViewController
and Bundle.
Complete picture
Solution 3
Swift 3 solution:
present( UIStoryboard(name: "CreateOrder", bundle: nil).instantiateViewController(withIdentifier: "firstOrderViewController") as UIViewController, animated: true, completion: nil)
Author by
Seth
Updated on February 04, 2020Comments
-
Seth over 4 years
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!