美文网首页
iOS 13 不使用storyboard 设置rootViewC

iOS 13 不使用storyboard 设置rootViewC

作者: 一直都是流年 | 来源:发表于2020-03-25 11:14 被阅读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()
    }

相关文章

网友评论

      本文标题:iOS 13 不使用storyboard 设置rootViewC

      本文链接:https://www.haomeiwen.com/subject/pqjtuhtx.html