美文网首页
‘UIScene‘ is only available in i

‘UIScene‘ is only available in i

作者: 不安分的夏 | 来源:发表于2023-07-26 19:29 被阅读0次

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

相关文章

网友评论

      本文标题:‘UIScene‘ is only available in i

      本文链接:https://www.haomeiwen.com/subject/xqmkpdtx.html