【问题标题】:Initial screen on iOS simulator is blackiOS模拟器上的初始屏幕是黑色的
【发布时间】:2021-10-02 19:41:19
【问题描述】:

我有以编程方式创建的 UIViewController。这是代码。即使将我的 SignUpViewController 背景设置为白色。启动时出现黑屏

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        startWindowLoad()
        return true
    }

//extension with the starter function 
extension AppDelegate {
    func startWindowLoad () {
        let startView = SignUpViewController()
        let navView = UINavigationController()
        navView.pushViewController(startView, animated: true )
        window = UIWindow(frame: UIScreen.main.bounds)
        window?.makeKeyAndVisible()
        window?.rootViewController = startView
        
    }
}

【问题讨论】:

标签: ios swift uiviewcontroller appdelegate


【解决方案1】:

在现代应用中,不使用应用委托窗口。您需要使用场景委托窗口。将所有代码移到场景委托中。

【讨论】:

    【解决方案2】:

    这可能是因为您的应用以 LaunchScreen 开头

    转到Info.plist 和 将Launch screen interface file base name 更改为Main

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-15
      • 2014-12-03
      • 1970-01-01
      • 1970-01-01
      • 2018-08-29
      • 2022-08-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多