Ios 如何保持在启动屏幕上,直到场景代理中的自动登录完成?

Ios 如何保持在启动屏幕上,直到场景代理中的自动登录完成?,ios,swift,xcode,uiscenedelegate,Ios,Swift,Xcode,Uiscenedelegate,我尝试在场景代理中自动登录后切换屏幕,除了启动屏幕出现10毫秒,然后它转到我的ViewController(初始视图控制器),然后它将屏幕切换到我希望它切换到的屏幕之外,其他一切都正常。我的目标是在我登录场景代理时始终显示启动屏幕,然后在登录完成后切换屏幕。这是我正在使用的代码 var window: UIWindow? func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connec

我尝试在场景代理中自动登录后切换屏幕,除了启动屏幕出现10毫秒,然后它转到我的ViewController(初始视图控制器),然后它将屏幕切换到我希望它切换到的屏幕之外,其他一切都正常。我的目标是在我登录场景代理时始终显示启动屏幕,然后在登录完成后切换屏幕。这是我正在使用的代码

var window: UIWindow?


    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).


        if let windowScene = scene as? UIWindowScene {
                  let window = UIWindow(windowScene: windowScene)
                  let storyboard = UIStoryboard(name: "Main", bundle: nil)
                  if KeychainWrapper.standard.string(forKey: "email") != nil && KeychainWrapper.standard.string(forKey: "password") != nil {
                        Auth.auth().signIn(withEmail: KeychainWrapper.standard.string(forKey: "email")!, password:  KeychainWrapper.standard.string(forKey: "password")!) { (result, error) in
                               if error == nil {
                                    if Auth.auth().currentUser!.isEmailVerified {
                                       /*getting data*/
                                         window.rootViewController = storyboard.instantiateViewController(identifier: "ViewingScreenController") 
                                          self.window = window
                                          window.makeKeyAndVisible()
                                     }
                                     
                           }
                                              
                        }
                                         
                     }
               }
    

        
      // guard let _ = (scene as? UIWindowScene) else { return }
    }```

你误解了启动屏幕是什么。在你的应用程序启动之前,它只是运行时提供的一种过渡。在许多情况下,它根本看不见!这很好,因为这意味着应用程序启动得很快。请参阅我的答案


因此,您不应该围绕启动屏幕构建任何功能;它不起作用。你的目标应该是通过启动屏幕,这意味着你的应用程序启动得很快,这是正确的。你现在做什么取决于你自己;您的代码正在运行。

您所说的“启动屏幕”是什么意思?你是说LaunchScreen.storyboard吗?如果是这样的话,你就误解了这是什么。@matt是的,我的意思是LaunchScreen.storyboard。它不执行该功能吗?在自动记录完成之前,您可以显示某些特定视图。它可以看起来与启动屏幕相同。但在加载应用程序之前,将显示启动屏幕。我也这么想,但我想知道的是,最好的解决办法是什么