我今天在控制台看到了这个错误,[ApplicationLifecycle] UIWindows were created prior to initial application activation. This may result in incorrect visual appearance.
这导致应用程序的UI表现不正常。我之前从未见过这种情况,需要一些启示来开始调试。
macOS: Catalina 10.15
XCode version: Version 11.1
我今天在控制台看到了这个错误,[ApplicationLifecycle] UIWindows were created prior to initial application activation. This may result in incorrect visual appearance.
这导致应用程序的UI表现不正常。我之前从未见过这种情况,需要一些启示来开始调试。
macOS: Catalina 10.15
XCode version: Version 11.1
我认为应该延迟初始化应用程序的主UIWindow
。请尝试使用以下代码:
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
lazy var window: UIWindow? = UIWindow(frame: UIScreen.main.bounds)
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
window?.rootViewController = RootViewController() // root view controller
window?.makeKeyAndVisible()
return true
}
}