How do I change "initwithNibName" in storyboard? How do I change "initwithNibName" in storyboard? xcode xcode

How do I change "initwithNibName" in storyboard?


The UIStoryboard class is your friend:

UIStoryboard* sb = [UIStoryboard storyboardWithName:@"mystoryboard"                                              bundle:nil];UIViewController* vc = [sb instantiateViewControllerWithIdentifier:@"ExampleViewController"];


  • If it is still in its own xib file, then you don't change anything.
  • If you've moved everything into a storyboard, then you wouldn't often need to do this as you'd link between view controllers using segues.

If neither of the above are true, i.e. your view controller is on the storyboard but no segue connects to it, then you want UIStoryboard's instantiateViewControllerWithIdentifier: method described in the documentation. You have to set the identifier in the storyboard for this to work.