iOS开发中遇到的bug和小技巧汇总

Xcode11:UIWindow 不能在AppDelegate中

2019-11-26  本文已影响0人  Sxiaobai
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        guard let windowS = (scene as? UIWindowScene) else { return }
        let vc = ViewController()
        let nav = UINavigationController(rootViewController: vc)

         //初始化window时,要用windowS:这个方法拿到windowS来初始化,否则初始化后的界面是黑的
        window = UIWindow(windowScene: windowS)
        window?.rootViewController = nav
        window?.makeKeyAndVisible()
    }
上一篇 下一篇

猜你喜欢

热点阅读