SwiftUI Beta 3黑屏
我刚刚转换到beta 3,我以前使用的SwiftUI代码现在呈现一个普通的黑屏。beta 3中是否有导致这种情况的变化。有解决办法吗 场景代理代码:SwiftUI Beta 3黑屏,swift,swiftui,xcode11,Swift,Swiftui,Xcode11,我刚刚转换到beta 3,我以前使用的SwiftUI代码现在呈现一个普通的黑屏。beta 3中是否有导致这种情况的变化。有解决办法吗 场景代理代码: func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { // Use this method to optionally config
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
// Use a UIHostingController as window root view controller
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = UIHostingController(rootView: ContentView())
self.window = window
window.makeKeyAndVisible()
}
场景Delgate的Beta 3工作版本:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
// Use a UIHostingController as window root view controller
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
window.rootViewController = UIHostingController(rootView: ContentView())
self.window = window
window.makeKeyAndVisible()
}
}
为了澄清,beta 1使用了
UIWindow(框架:…)
,现在已改为UIWindow(windowScene:…)
。传递的参数现在是当前场景,并将类型转换为UIWindowScene
我的项目中没有脚本,所有UI都是以编程方式编码的(不是swift UI)
在启动应用程序时,在启动屏幕之后,唯一的黑屏出现了
对我有效的解决办法是,
我已从常规设置中禁用/取消选中“支持多个窗口”
我在beta 2中创建了当前项目,我得到了您发布的第一个场景代理,您创建此项目时使用的是哪个beta?@Sudara我想我的原始代码来自beta 1。我认为这与昨天beta 3的变化有关。嗯……有什么区别?我也有同样的问题,但我还没有解决it@nunzio仔细查看更新后的代码。如果让windowScene=scene作为?UIWindowScene在原始代码块之前。@DavidL对不起,我的答案不明显。即使如此,它对我的meSame场景也不起作用,但我的场景从未被检查过,所以这对我不起作用