Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add storyboard in 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?

like image 228
Harish Avatar asked Dec 23 '15 15:12

Harish


People also ask

How do I add a storyboard to an existing Xcode project?

Add new storyboard to the project by File->New->File... ->Userinterface->storyboard. Go to project summary and select MainStoryboard and select the storyboard name you just created.

Can you combine SwiftUI with storyboard?

The answer is YES! Here we will be discussing a simple way to use SwiftUI into our existing project, which already consists of a storyboard. Let's dive in then!


1 Answers

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
like image 151
nsinvocation Avatar answered Oct 23 '22 00:10

nsinvocation