今天用Xcode新建了一个Swift工程,直接选择支持最低版本iOS9后运行报错:'UIScene' is only available in iOS 13.0 or newer。 也就是iOS13以后出现了UIScene这个东西,应该是为多窗口应用准备的。
我这里只需要单窗口应用程序且不使用storyboard,所以要进行以下操作:
1.删除SceneDelegate.swift文件,同时删除AppDelegate.swift里UISceneSession Lifecycle相关函数;
2.删除info.plist中的Main storyboard file base name和Scene Configuration配置;
3.在AppDelegate中实现如下方法即可正常运行:
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
window = UIWindow.init(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
window?.rootViewController = ViewController.init()
return true
}
更多推荐
‘UIScene‘ is only available in iOS 13.0 or newer
发布评论