【发布时间】:2014-08-21 16:50:03
【问题描述】:
我想出了如何在应用程序启动时呈现两个不同的视图控制器,如果我不以模态方式呈现它们,它就可以正常工作。如果我更改代码,它会以某种方式显示空白视图控制器。
从 -> self.window.rootViewController = 登陆VC;
To-> [self.window.rootViewController presentViewController:landingVC animated:YES completion:nil];
这是我的应用委托中的完整代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *tabbarController = [storyboard instantiateViewControllerWithIdentifier:@"TabBarViewController"];
UIViewController *landingVC = [storyboard instantiateViewControllerWithIdentifier:@"LandingViewController"];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HasLaunchedOnce"]) {
self.window.rootViewController = tabbarController;
} else {
[self.window.rootViewController presentViewController:landingVC animated:YES completion:nil];
}
[self.window makeKeyAndVisible];
return YES;
}
AFAIK,这就是 modalVC 的显示方式。我已经验证了 storyboardID 并检查了两个视图控制器的“使用 storyboardID”。
【问题讨论】:
标签: ios storyboard