我遇到的问题是删除 Storyboard上的根箭头并在AppDelegate文件中设置 Root View 以动态更改RootView。
移动 Root View 没有问题,但现有的splashScreen(Launch Screen)
不可见。为什么你看不到?如何查看 splashScreen(Launch Screen)
并转到 Root View ?
主 Storyboard
登录.Storyboard,
启动 Storyboard
在 AppDelegate.swift 中移动根屏幕
var window: UIWindow?
func switchStartUI() {
let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = mainStoryboard.instantiateViewController(withIdentifier: "StartViewController")
self.window?.rootViewController = viewController
}
func switchToMainUI() {
let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = mainStoryboard.instantiateViewController(withIdentifier: "NavigationController")
self.window?.rootViewController = viewController
}
func switchLoginUI(_ pushtype : String) {
let loginStoryboard = UIStoryboard(name: "Login", bundle: nil)
let viewController = loginStoryboard.instantiateViewController(withIdentifier: "MainLoginController") as! MainLoginController
viewController.pushType = pushtype
self.window?.rootViewController = viewController
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
self.window = UIWindow(frame: UIScreen.main.bounds)
if let screenData : String = LocalStorage.get("ScreenView") as? String {
switch (screenData) {
case "success":
switchToMainUI()
case "success1":
switchLoginUI("")
case "success2":
switchLoginUI("")
default:
switchStartUI()
}
} else {
switchStartUI()
}
self.window?.makeKeyAndVisible()
return true
}
我想查看启动屏幕并转到 Root View
我的启动屏幕上已经有一个图像。它工作正常。但是动态修改 Root View 后我看不到闪屏。我也是这样的
我只能看到黑屏。当删除两个函数时
self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.makeKeyAndVisible()
对我来说,出现白屏,然后我进入 Root View 页面。
我不知道为什么看不到启动画面。
如何解决这个问题?
提前致谢
最佳答案
关于ios - 为什么在 swift 5 中更改 Root View 时看不到启动(启动)屏幕?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58262479/