首先進來這裡把 Main 給砍掉,再把你的 Main.storyboard 砍掉
並新創一個 View Controller ,也勾選 also create XIB file
進到 AppDelegate,再到 didFinishLaunchingWithOptions 加入 Root View Controller ,UIWindow 有一個屬性是用來顯示根 view controller - rootViewController ,只要將需要第一個顯示的 view controller 丟給她,在 app 開啟時,就會幫我們在顯示 launch image 之後第一個顯示出來。
self.window = UIWindow(frame: UIScreen.main.bounds)
let nvc = UINavigationController(rootViewController: NewVC())
self.window?.rootViewController = nvc
self.window?.makeKeyAndVisible()
SceneDelegate 找到 func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions)
guard let windowScene = (scene as? UIWindowScene) else { return }
let nvc = UINavigationController(rootViewController:NewVC())
self.window = UIWindow(frame: windowScene.coordinateSpace.bounds)
window?.windowScene = windowScene
//後面接一開始的ViewController
self.window?.rootViewController = nvc
// 把 window 顯示出來
self.window?.makeKeyAndVisible()
這樣就大功告成囉