How do I change "initwithNibName" in storyboard?

jokor7 picture jokor7 · Jan 13, 2012 · Viewed 38.2k times · Source

I want to change below code with storyboard with Xcode 4.2.

UIViewController * example     = [[ExampleViewController alloc] initWithNibName:@"ExampleViewController" bundle:nil];

Now ExampleViewController.xib file exist. but I want to make it with storyboard. please help me. (I'm not good at English. Sorry)

Answer

Stephen Darlington picture Stephen Darlington · Jan 13, 2012

The UIStoryboard class is your friend:

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