刪除SceneDelegate 回復舊有AppDelegate 🤙
簡介
如何刪除SceneDelegate? Xcode新版本添加了SceneDelegate區隔了畫面與功能,如果你還不習慣想刪除SceneDelegate可以參考這篇
1. 刪除SceneDelegate.swift檔案
2.刪除AppDelegate有關UISceneSession Lifecycle的Code
AppDelegate.swift
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
3.在AppDelegate加入window
var window: UIWindow?
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow? //新增
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
return true
}
}