我目前正在向我的 iOS 应用程序添加 Firebase 身份验证。我可以注册并登录用户,但是,我很难找到可以添加转场以进入下一个屏幕的位置。
func signInUser(email: String, password: String){
// creates user with the firebase autenthication platform
Auth.auth().signIn(withEmail: email, password: password) { [weak self] authResult, error in
guard let strongSelf = self else { return }
}
// would the segue go here?
}
答案 0 :(得分:1)
您应该在 signIn
函数完成处理程序中执行您的代码:
func signInUser(email: String, password: String){
//creates user with the firebase autenthication platform
Auth.auth().signIn(withEmail: email, password: password) { [weak self] authResult, error in
guard let strongSelf = self else { return }
if let error = error as? NSError {
// Handle sign in error
switch AuthErrorCode(error.code) {
...
}
} else {
// No errors: Perform segue here...
}
}
}