Search code examples
iosxcodestoryboardxib

How do I change "initwithNibName" in storyboard?


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)


Solution

  • The UIStoryboard class is your friend:

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