简体   繁体   English

即使显示出Firebase登录中发生错误,我的Swift代码也会执行segue

[英]My swift code performs a segue when even if it shows that an error is occuring in the firebase login

This is my code, the first part (Auth.auth.signin) is authenticating with Firebase if the emailId and password is correct. 这是我的代码,如果emailId和密码正确,则第一部分(Auth.auth.signin)正在使用Firebase身份验证。 After that, if incorrect, it print incorrect. 此后,如果不正确,则打印不正确。 This part does show up in the console. 这部分确实显示在控制台中。 However, the code performs the segue even though it is not supposed to. 但是,即使不执行该代码,代码也可以执行segue Why is this? 为什么是这样?

@IBAction func loginPressed(_ sender: Any) {
    //TODO: Log in the user
    Auth.auth().signIn(withEmail: emailTextfield.text!, password: passwordTextfield.text!) { (user, error) in
        print(error!)

        if(error != nil || user == nil){
            print("incorrect signin")
        }
        else{
            self.performSegue(withIdentifier: "goToChat", sender: self)
            print("Login was good")

        }
    }
}

Looks like you have assigned Segue from button. 看起来您已经从按钮分配了Segue Remove the older one and create new Segue like shown below: 删除较旧的版本并创建新的Segue如下所示:

在此处输入图片说明

And add identifier for Segue . 并为Segue添加标识符。

You have done segue from your button. 您已经完成了从按钮进行的​​segue。 Remove it and add Segue from View Controller to view controller. 删除它,并将Segue从View Controller添加到View Controller。

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

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