简体   繁体   English

未执行 Segue

[英]Segue is not being performed

I've created a method for auto login via Firebase but somehow my segue is not being performed..我已经创建了一种通过 Firebase 自动登录的方法,但不知何故我的 segue 没有被执行..

I've this code and in my viewDidLoad I'm calling the method (ofc)我有这个代码,在我的 viewDidLoad 中我正在调用方法(ofc)

override func viewDidLoad() {
super.viewDidLoad()

  //Login user automatically
  autoLogin()
}

func autoLogin(){
    if Auth.auth().currentUser?.email != nil{

        print("not nil") //for test
        self.performSegue(withIdentifier: "toRootVc", sender: self)
        print("not nil1") //for test
    }
    else{
        print("nil") //for test
    }
}

The app prints both "not nil" and "not nil1" but it still does not performing the segue.该应用程序打印“not nil”和“not nil1”,但它仍然不执行 segue。

I also have a login button which works.我还有一个可以使用的登录按钮。

func handleLogin(){
    Auth.auth().signIn(withEmail: email.text!, password: password.text!) { (result, err) in
        if let err = err{
            print("Error logging in:", err.localizedDescription)
        }
        else{
            self.databaseHandler.retrieveData(email: self.email.text!){
                self.performSegue(withIdentifier: "toRootVc", sender: self)
            }
        }
    }
}

But the autoLogin doesn't actually performing the segue.但是 autoLogin 实际上并没有执行 segue。 (Ignores the step) (忽略步骤)

Any input would be much appreciated.任何输入将不胜感激。

塞格斯不会里面工作viewDidLoad因为它太早期的尝试viewWillAppear或呈现的VC里面说以前好做此项检查didFinishLaunchingWithOptionsAppDelegate

你有没有试过把这个 autoLogin() 放在 viewDidAppear() 上

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM