Search code examples
swiftxcodestoryboard

Add multiple storyboards in project - Swift


How do you create multiple storyboards in the same project using Swift? I know I have to go to File -> New -> File and then choose Storyboard, but how do I integrate that storyboard into my project and navigate to the new storyboard's views in Swift code?


Solution

  • You need to get a reference to the desired storyboard

    let aStoryboard = UIStoryboard(name: "storyboardName", bundle: nil)
    

    Then instantiate desired view controller

    let vc = aStoryboard.instantiateViewControllerWithIdentifier("viewControllerIdentifier") as! UIViewController