hvr8qq
Last Updated: May 16, 2018
·
52.92K
· anthonylevings
Speechrocket4 square

Instantiate a view controller using a storyboard identifier in Xcode (iOS)

First of all give the view controller in your storyboard a Storyboard ID inside the identity inspector. Then use the following example code (ensuring the class, storyboard name and story board ID match those that you are using):

YourViewControllerClass *viewController = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@"ViewController"];

For more details see http://sketchytech.blogspot.com/2012/11/instantiate-view-controller-using.html

Say Thanks
Respond

3 Responses
Add your response

12536
35a19446af891332d5cad61f16ab9ab4

So what are the advantages to using this method of segues configured in a storyboard?

over 1 year ago ·
12543
Speechrocket4 square

Thanks for the comment. To explain, this isn't triggering a storyboard segue, this is instantiating a view controller that has been created visually in interface builder (or whatever you want to call that area of Xcode now).

over 1 year ago ·
29911

steps toInstantiate a view controller using a storyboard identifier in Xcode (iOS)

inn order to instantiate a view controller using a storyboard identifier in Xcode, you first need to assign a Storyboard ID to your view controller. In order to do this:

(1) select the storyboard file in your project

(2) select the view controller that you would like to instantiate

(3) with the view controller highlighted select the identity inspector in the utilities on the right-hand side of the window

(4) give your view controller a Storyboard ID
https://luckypatcher.pro/ https://kodi.software https://plex.software/

28 days ago ·