thank_you
thank_you

Reputation: 11097

Multiple Views For One Controller in Swift

I have a controller called PageViewController. Now I have created several view controllers in my storyboard. Ideally I would like to connect all of the view controllers in my storyboard to PageViewController and then when PageViewController is loaded, PageViewController will choose which view to display to the user.

I don't want to create the view programmatically since I'll also have to create numerous layout constraints to each view and that will be time consuming. My questions is this, since I connected multiple view controllers to PageViewController, is there a way for me to tell my app which view controller from the storyboard I want displayed for PageViewController.

Upvotes: 0

Views: 2089

Answers (1)

GaétanZ
GaétanZ

Reputation: 4930

Not sure of what you want but you can get your controller from your storyboard using its identifier :

let controller = self.storyboard!.instantiateViewControllerWithIdentifier("myControllerIdentifier") as! MyControllerClass

You can present it using presentViewController:

Upvotes: 1

Related Questions