我是来自 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/