【发布时间】:2020-02-29 02:28:20
【问题描述】:
我创建了一个通过 Firebase 自动登录的方法,但不知何故我的 segue 没有被执行..
我有这段代码,在我的 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
}
}
应用程序同时打印“not nil”和“not nil1”,但仍然没有 执行转场。
我还有一个可用的登录按钮。
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)
}
}
}
}
但 autoLogin 实际上并没有执行 segue。 (忽略步骤)
任何意见将不胜感激。
【问题讨论】: