ios - 在主故事板中设置根视图控制器
问题描述
所以我有这个故事板,如果用户未登录,我希望向用户显示登录视图控制器,否则显示标签视图控制器。这是我在应用程序委托中的代码:
`
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
UITabBar.appearance().tintColor = .white
// check user
let authListener = Auth.auth().addStateDidChangeListener { auth, user in
if user != nil {
print("USER IS NOT NIL")
userService.observeUserProfile(uid: user!.uid) { userProfile in
userService.currentUserProfile = userProfile
}
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "TabBarVC") as! UITabBarController
self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.rootViewController = vc
self.window?.makeKeyAndVisible()
} else {
print("USER IS NIL")
userService.currentUserProfile = nil
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "FirstVC") as! UIViewController
vc.modalPresentationStyle = .fullScreen
self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.rootViewController = vc
self.window?.makeKeyAndVisible()
}
}
}
` 我的问题是,如果用户没有登录,它看起来像这样:
如您所见,即使我在应用程序委托中指定了视图,视图也不是全屏的,因此用户可以简单地关闭它并进入主屏幕。同样在标签视图控制器中,我有一个播放视频的主屏幕,登录屏幕也有一个在后台播放的视频,两个视频同时播放 XD。欢迎提供任何提示。
解决方案
更改情节提要--> 视图控制器--> 属性检查器--> 将演示文稿从自动更改为全屏
推荐阅读
- objective-c - 为 UIImageViwe 添加乘数时未获得 UIImageView 圆形边框
- java - Java类中的单个静态字段
- linux - 在 Linode 服务器上升级 openssl 但如何决定“ENGINESDIR”
- unit-testing - vue.js vuetify : test-utils w Jest 如何在使用图标时匹配文本
- metal - 剪刀矩形在金属中的极限是多少?
- ruby-on-rails - 如何避免在苗条视图中两次使用相同的条件
- php - 该代码仅输出第一行
- visual-studio - Servicenow 请求正文超出了允许的最大内容长度
- sql-server - 在 SQL Server CTE 中添加 where 子句
- java - 带有 java 和 kotlin Function 参数的 Kotlin 2 方法(无法从 java 访问)