Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I give an "identifier" to a view controller within my storyboard?

The instantiateViewControllerWithIdentifier: method requires that the view controller I pass have an identifier. I went to my storyboard and clicked on my view controller, but I see no option to set the identifier. Where exactly do I find this option?

like image 956
Doug Smith Avatar asked Mar 18 '13 13:03

Doug Smith


People also ask

How do I set the identifier for view controller in storyboard?

In the Storyboard, select the view controller that you want to instantiate in code. Make sure the yellow circle is highlighted, and click on the Identity Inspector. Set the custom class as well as the field called "Storyboard ID". You can use the class name as the Storyboard ID.

What are storyboard identifiers for?

A storyboard ID does exactly what the name implies: it identifies. Just that it identifies a view controller in a storyboard file. It is how the storyboard knows which view controller is which.

How do I embed a view controller in navigation controller storyboard?

In your storyboard, select the initial view controller in your hierarchy. With this view controller selected, choose the menu item Editor -> Embed In -> Navigation Controller .


2 Answers

As the Image suggests! Hope it helps!

enter image description here

Then to use it you call:

[self.storyboard instantiateViewControllerWithIdentifier:@"YourViewControllerID"]; 
like image 87
Groot Avatar answered Sep 20 '22 02:09

Groot


Updated for XCode 8 and Swift 3.

instantiateViewControllerWithIdentifier is now instantiateViewController(withIdentifier:).

Setting the storyboard ID: enter image description here

like image 30
Taiwosam Avatar answered Sep 21 '22 02:09

Taiwosam