新建的项目出现SceneDelegate,并且项目设置低于13的系统会报错,因为SceneDelegate 是iOS 13才出现的,解决办法如下:
如果我们不开发iPadOS多窗口APP,SceneDelegate窗口管理我们可以删除。
1.删除掉info.plist中Application Scene Manifest选项,
截屏2020-01-13上午11.23.28.png
2.同时,文件SceneDelegate删除
3.Appdelegate相关代码注释掉
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
}
//注释掉这两个方法。
4.Appdelegate新增windows属性
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
//如果是用默认的storyboard,下面的代码可以不写
// window = UIWindow.init()
// window?.frame = UIScreen.main.bounds
// window?.makeKeyAndVisible()
// window?.rootViewController = UIStoryboard.init(name: "Main", bundle: nil).instantiateInitialViewController()
return true
}
///做完这些就跟以前一样啦。