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()
}