iOS-Swift新工程navigationController无效

244 阅读1分钟

1、删除SceneDelegate.swift文件

2、删除Info.plist的UIApplicationSceneManifest属性结构

3、修改AppDelegate.swift文件 删除UISceneSession Lifecycle 的两个方法,然后在didFinishLaunchingWithOptions内创建自己的window和rootViewController

import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        window = UIWindow()
        self.window?.backgroundColor = UIColor.white
        self.window?.rootViewController = UINavigationController.init(rootViewController: ViewController())
        window?.makeKeyAndVisible()
        return true
    }


}