How to programmatically set initial view controller using Storyboard
If for some reasons, you don’t want to use the Automatic setting initial view control feature of Storyboard, here is the solution
Step 1: Make sure that view controller (the view controller you want to make it initial) has StoryboardID
Step 2: Disable that view controller ‘s Is Initial View Controller
Step 3: Remove Main storyboard file base name value in app Target Info
Step 4: Some code in AppDelegate.m
[code language=”objc”]
-
(BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions
{
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@”MainStoryboard_iPhone”bundle: nil];
MainViewController mainViewController = (MainViewController)[mainStoryboard
instantiateViewControllerWithIdentifier: @"SBMainViewController"];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:mainViewController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window setRootViewController:navigationController];
[self.window setBackgroundColor:[UIColor whiteColor]];
[self.window makeKeyAndVisible];return YES;
}
[/code]