我收到以下警告,应用程序显示iOS 13黑屏
iOS 13
UIWindowSceneSessionRoleApplication的[场景配置] Info.plist配置“(无名称)”包含UISceneDelegateClassName键,但无法加载名为MyApp.SceneDelegate的类。如何解决此问题?
Info.plist
f5emj3cl1#
SceneDelegate在iOS 13之后已受支持。如果您想使用SceneDelegate并且还想支持iOS 13之前的iOS,则必须在项目中进行一些更改。如果iOS 13可用,则执行SceneDelegate。
SceneDelegate
@available(iOS 13.0, *) class SceneDelegate: UIResponder, UIWindowSceneDelegate { //Other code } @available(iOS 13.0, *) func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) { }
class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? }
AppDelegate需要UIWindow属性。iOS 13在新项目中使用SceneDelegate。请指定UIWindow对象并移除SceneDelegate.swift文件。如果已从项目中删除SceneDelegate,则必须从Info.plist中删除应用程序场景清单字典。
UIWindow
SceneDelegate.swift
4uqofj5v2#
如果除默认场景外未使用其他自定义场景,请从Info.plist中删除“UISceneClassName”。
<key>UISceneClassName</key> <string></string>
2条答案
按热度按时间f5emj3cl1#
SceneDelegate
在iOS 13之后已受支持。如果您想使用SceneDelegate
并且还想支持iOS 13之前的iOS,则必须在项目中进行一些更改。如果iOS 13可用,则执行
SceneDelegate
。代码:
在AppDelegate.swift中添加UIWindow对象
适用于iOS 12及更低版本
AppDelegate需要UIWindow属性。iOS 13在新项目中使用SceneDelegate。请指定
UIWindow
对象并移除SceneDelegate.swift
文件。如果已从项目中删除
SceneDelegate
,则必须从Info.plist中删除应用程序场景清单字典。4uqofj5v2#
如果除默认场景外未使用其他自定义场景,请从Info.plist中删除“UISceneClassName”。