- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIViewController *rootVC;
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
if(![[NSUserDefaults standardUserDefaults] boolForKey:@"logged_in"]) {
rootVC=[self.storyboard instantiateViewControllerWithIdentifier: @"vc1"];
} else {
rootVC=[self.storyboard instantiateViewControllerWithIdentifier: @"vc2"];
}
window.rootViewConroller=rootVC;
[self.window makeKeyAndVisible];
return YES;
}
这里面的“vc1”和“vc2”,其实就是storyboard的表示符,自己在创建storyboard的时候一般都会看到的,如果自己还不知道的话,多创建几个自己就知道了。
-----------------------------------------
//主要的storyboard - xunYi7TabBarViewController
//login的storyboard - login
UIViewController *rootViewController;
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
if([[NSUserDefaults standardUserDefaults] boolForKey:@"logged_in"]) {
rootViewController = [[UIStoryboard
storyboardWithName:@"MainStoryboard" bundle:nil]
instantiateViewControllerWithIdentifier:@"xunYi7TabBarViewController"];
}else{
rootViewController = [[UIStoryboard
storyboardWithName:@"LoginStoryboard" bundle:nil]
instantiateViewControllerWithIdentifier:@"login"];
}
self.window.rootViewController=rootViewController;
[self.window makeKeyAndVisible];
return yes;
不同的storyboard可以有不同的设置
原文:http://www.gowhich.com/blog/273 , http://www.gowhich.com/blog/268