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

标签 ios xcode

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

相关文章:

android - 使网站适合移动设备的最佳方法是什么?

sql - 是否直接执行SQL错误的应用程序设计?

ios - 尝试在 iOS 应用程序中实现 FB 身份验证时出错

c++ - Apple clang 编译器版本控制架构?

ios - 使用导航 Controller 时保留标题 View

ios - Xcode - 没有可供下载的 dSYM

ios - 子元素在 safari 浏览器中不占据父元素的焦点

iphone - xcode 在选择之前加载 tabContent

swift - 如何在两个 View Controller 之间发送结构数组?

ios - 如何在 Xcode 7 上成功上传二进制文件而不会出现此错误?