iOS 13 不使用storyboard 设置rootViewC

2020-03-25  本文已影响0人  一直都是流年

遇到不使用storyboard设置rootViewController ,根据很久之前的经验,在appdelegate中的window中设置,结果无效,然后看到了sceneDelegate这个文件,在这个方法中设置

    @available(iOS 13.0, *)
    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 windowScene = (scene as? UIWindowScene) else { return }
        self.window = UIWindow(windowScene: windowScene)
        let splash = SplashViewController()
        self.window?.rootViewController = splash
        self.window?.makeKeyAndVisible()
    }
上一篇 下一篇

猜你喜欢

热点阅读