一、 ios13中创建项目(不使用SceneDelegate)步骤:
AppDelegate添加window,用于 iOS 13 以下加载rootViewController
1)删除SceneDelegate.swift
2)删除 Main.storyboard,不使用storyboard布局,打开info.plist,删除Main storyboard file base name和Application Scene Manifest选项。
3)删除appdelegate 中关于scene的2个代理
4)appdelegate中添加根导航
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = LYBTabBarVC.init()
self.window?.backgroundColor=UIColor.white
self.window = window
window.makeKeyAndVisible()
return true
}
二、ios13创建项目(使用SceneDelegate):
SceneDelegate用于 iOS 13加载rootViewController
在SceneDelegate.swift中的scene方法中添加
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
//方法一guard let _ = (scene as? UIWindowScene) else { return }
let window=UIWindow(windowScene: scene as! UIWindowScene)
window.rootViewController = LYBTabBarVC.init()
self.window=window
window.makeKeyAndVisible()
方法二:
if let windowSence = scene as? UIWindowScene {
self.window = UIWindow(windowScene: windowSence)
let tabvc = LYBTabBarVC.init()
self.window?.rootViewController = tabvc
self.window?.makeKeyAndVisible()
}
}