【发布时间】:2020-09-24 02:43:50
【问题描述】:
在 iOS 13 中,我无法加载 TabBarViewController。 iOS 13.0以下版本,运行正常。
public static func updateRootVC(){
var rootVC = UIViewController()
let appDelegate = UIApplication.shared.delegate as! AppDelegate
if(status == true){
let tabBarController = UIStoryboard(name: AppStoryboard.dashboard.rawValue, bundle: nil).instantiateViewController(withIdentifier: "TabBarController") as! TabBarController
appDelegate.window?.rootViewController = tabBarController
}
else{
let welcomeViewController = UIStoryboard(name: AppStoryboard.main.rawValue, bundle: nil).instantiateViewController(withIdentifier: "WelcomeViewController") as! WelcomeViewController
rootVC = UINavigationController.init(rootViewController: welcomeViewController)
rootVC.addChild(welcomeViewController)
appDelegate.window?.rootViewController = rootVC
}
}
我在我的项目中手动包含了SceneDelegate,它对此有什么影响吗?
您的解决方案应该从 iOS 13.0 版本开始工作。
【问题讨论】:
-
从 iOS 13 开始,您应该使用 SceneDelegate 而不是 AppDelegate 进行此类操作。你可以在网上找到一堆教程。
标签: ios swift ios13 appdelegate