简体   繁体   English

ViewController 未从 iOS 13.0 版本开始加载

[英]ViewController not loading from iOS 13.0 version onwards

In iOS 13, I was unable to load the TabBarViewController .在 iOS 13,我无法加载TabBarViewController Below the iOS 13.0 version, it's working fine.在 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
    }
}

I manually included SceneDelegate inside my project, does it have any impact on this?我在我的项目中手动包含SceneDelegate ,它对此有什么影响吗?

Your solution should work from version iOS 13.0 onwards.您的解决方案应从版本 iOS 13.0 开始运行。

as commented before since iOS 13 sceneDelegate is introduced to handle multiple scene apps so if you have Scene delegate file then you must rewrite the function as this to use the window property in the scene delegate since is removed from AppDelegate.正如之前评论的那样,因为 iOS 13 sceneDelegate 被引入来处理多个场景应用程序,所以如果你有场景委托文件,那么你必须重写 function ,因为它已从 AppDelegate 中删除,因此在场景委托中使用 window 属性。

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
    if #available(iOS 13, *) {
        UIApplication.shared.windows.first?.rootViewController = tabBarController
        UIApplication.shared.windows.first?.makeKeyAndVisible()
    }else{        
        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)
    if #available(iOS 13, *) {
        UIApplication.shared.windows.first?.rootViewController = rootVC
        UIApplication.shared.windows.first?.makeKeyAndVisible()

    }else{        
        appDelegate.window?.rootViewController = tabBarController
    }
} 

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 来自.xib文件的ViewController在iOS中以纵向模式而不是横向模式加载 - ViewController from .xib file is loading in portrait mode and not in landscape mode in iOS ViewController无法在iOS 4.3上运行的ARC项目中从笔尖加载子视图? - ViewController not loading subviews from nib in ARC project running on iOS 4.3? ViewController加载两次Xcode iOS - ViewController loading twice xcode iOS 从ViewController加载SKScene - Loading a SKScene from a ViewController 加载ViewController之前先加载ViewController - Loading ViewController before loading Data is IOS UIPanGestureRecognizer 不适用于 iOS 13.0 - UIPanGestureRecognizer not working on iOS 13.0 iOS/Objective-c:如何在 .h 文件中获取表示版本高于或等于 13.0 的宏? - iOS/Objective-c: How to get a macro that says the version is higher or equal to 13.0 in the .h file? iOS:从LandScape ViewController切换到Portrait ViewController - iOS: Switching to Portrait ViewController from LandScape ViewController WhatsApp 网络客户端如何仍然使用最新的 iOS 更新(SDK 版本 13.0+)? - How does the WhatsApp web client still work with the latest iOS update (SDK version 13.0+)? IOS 5 - 从另一个ViewController调用ViewController - IOS 5 - Call a ViewController from another ViewController
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM