相关疑难解决方法(0)

在appdelegate中设置初始viewcontroller - swift

我想从appdelegate设置初始viewcontroller.我找到了一个非常好的答案,但它是在Objective C中,我很难在swift中实现同样的功能.

使用Storyboard以编程方式设置初始视图控制器

- (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;
}
Run Code Online (Sandbox Code Playgroud)

有人能帮忙吗?

我希望初始Viewcontroller依赖于使用条件语句满足的某些条件.

ios

133
推荐指数
13
解决办法
15万
查看次数

标签 统计

ios ×1