Reputation: 611
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)
Upvotes: 55
Views: 38514
Reputation: 52565
The UIStoryboard
class is your friend:
UIStoryboard* sb = [UIStoryboard storyboardWithName:@"mystoryboard"
bundle:nil];
UIViewController* vc = [sb instantiateViewControllerWithIdentifier:@"ExampleViewController"];
Upvotes: 133
Reputation: 119292
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.
Upvotes: 8