How set rootViewController in Scene Delegate iOS 13

后端 未结 4 2060
无人共我
无人共我 2020-12-10 20:40

Before changes in UIKit iOS 13 how I can set rootViewController at SceneDelegate?

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

    var window:          


        
4条回答
  •  一生所求
    2020-12-10 21:32

    Like this:

    class SceneDelegate: UIResponder, UIWindowSceneDelegate {
    
       var window: UIWindow?
       func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
             // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
             // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
             // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
            guard let _ = (scene as? UIWindowScene) else { return }
    
            let rootVC = self.window?.rootViewController 
        }
        // ... the rest of SceneDelegate
    }
    

    As seen here.

提交回复
热议问题