我想从appdelegate设置初始的视图控制器。我找到了一个非常好的答案,但是它是用Objective C编写的,我在Swift中尝试实现同样的内容时遇到了困难。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *viewController = // determine the initial view controller here and instantiate it with [storyboard instantiateViewControllerWithIdentifier:<storyboard id>];
self.window.rootViewController = viewController;
[self.window makeKeyAndVisible];
return YES;
}
有人能帮忙吗?
我想让初始视图控制器依赖于某些条件,使用条件语句来实现。