我试图在我的场景委托中自动登录后切换屏幕,一切正常,除了我的启动屏幕出现 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 }
}```