gpt4 book ai didi

iOS - 在 LaunchScreen 后设置第一个屏幕

转载 作者:行者123 更新时间:2023-11-28 23:29:26 26 4
gpt4 key购买 nike

我是来自 Android 背景的 iOS 开发新手,我希望在启动屏幕之后设置第一个屏幕。

我相信相关代码是

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
rootViewController = [UITabBarController new];
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
[self setup];

我想设置为第一个屏幕的屏幕的 XIB 文件称为 LoginView.xib

我需要做什么?

我使用的样板应用是 Swift 和 Objective C 的混合体

谢谢

最佳答案

您还需要设置应由选项卡栏 Controller 处理的 View Controller 。在您的情况下,您需要实例化在 LoginView.xib 中显示 View 的 View Controller - 我假设它称为 LoginViewController:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
rootViewController = [UITabBarController new];
LoginViewController *lvc = [[LoginViewController alloc] init];
// SecondViewController *secondVC = [[SecondViewController alloc] init];
// ThirdViewController *thirdVC = [[ThirdViewController alloc] init];
rootViewController.viewControllers = @[lvc /*, secondVC, thirdVC */ ];
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
[self setup];

如果您最初不需要标签栏 Controller ,那么只需使用

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
rootViewController = [LoginViewController new];
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
[self setup];

关于iOS - 在 LaunchScreen 后设置第一个屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57290071/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com