简体   繁体   中英

Unable to set root view controller while supporting iOS 12 & iOS 13

I'm facing a issue while setting the root view controller. I'm changing the root view controller after my tutorial is completed, I have a method in app delegate class which changes rootviewcontroller which i'm calling using shared instance of app delegate. This works proper with iOS 12 and below but in 13 it doesn't may be because in 13 Scene Delegate comes in Picture. Can anyone help me how with this issue??

It is available in SceneDelegate.swift file in your project

It will have delegate method:

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions)

comple code here:

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {

if let windowScene = scene as? UIWindowScene {

    self.window = UIWindow(windowScene: windowScene)

    let viewController =
        storyboard.instantiateViewController(withIdentifier: "viewController")
    self.window!.rootViewController = viewController
    self.window!.makeKeyAndVisible()
}
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM