为了确保在以编程方式完成所有 *** 作后都能在iOS 13中看到根视图控制器,您必须执行以下 *** 作:
在场景委托中,必须创建窗口实例和根视图控制器:
class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let winScene = (scene as? UIWindowScene) else { return } // Create the root view controller as needed let vc = ViewController() let nc = UINavigationController(rootViewController: vc) // Create the window. Be sure to use this initializer and not the frame one. let win = UIWindow(windowScene: winScene) win.rootViewController = nc win.makeKeyAndVisible() window = win }}
您的Info.plist必须具有“应用程序场景清单”条目。它下面应是“启用多个Windows”条目。根据您的应用设置为是或否。(可选)您还应该具有“场景配置”条目。
当您在目标的“常规”选项卡上选中“支持多个窗口”设置时,所有这些条目均由Xpre添加。这将默认将“启用多个窗口”(Enable Multiple
Windows)条目设置为“是”(YES),因此,如果您需要场景但不需要多个窗口,则可以将其更改为“否”。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)