‘UIScene‘ is only available in iOS 13.0 or newer

今天用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配置;

删除 Application Scene Manifest 

3.在AppDelegate中实现如下方法即可正常运行:

@main

class AppDelegate: UIResponder, UIApplicationDelegate {

    varwindow:UIWindow?

    funcapplication(_application:UIApplication,didFinishLaunchingWithOptionslaunchOptions: [UIApplication.LaunchOptionsKey:Any]?) ->Bool{

        // Override point for customization after application launch.

        window = UIWindow.init(frame: UIScreen.main.bounds)

        window?.backgroundColor = .lightGray

        window?.makeKeyAndVisible()

        window?.rootViewController = ViewController.init()

        return true

    }


}

https://blog.csdn.net/weixin_38735568/article/details/101266408/
iOS 13 SceneDelegate适配

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容