Storyboard - refer to ViewController in AppDelegate
Have a look at the documentation for -[UIStoryboard instantiateViewControllerWithIdentifier:]
. This allows you to instantiate a view controller from your storyboard using the identifier that you set in the IB Attributes Inspector:
EDITED to add example code:
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard"
bundle: nil];
MyViewController *controller = (MyViewController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"<Controller ID>"];
If you use XCode
5 you should do it in a different way.
- Select your
UIViewController
inUIStoryboard
- Go to the
Identity Inspector
on the right top pane - Check the
Use Storyboard ID
checkbox - Write a unique id to the
Storyboard ID
field
Then write your code.
// Override point for customization after application launch.
if (<your implementation>) {
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main"
bundle: nil];
YourViewController *yourController = (YourViewController *)[mainStoryboard
instantiateViewControllerWithIdentifier:@"YourViewControllerID"];
self.window.rootViewController = yourController;
}
return YES;