Swift firebase google登录后如何关闭视图
我有swift 4 firebase谷歌登录的代码。问题是在登录后,它只是将我放回到用于登录的视图上。在哪里执行代码以在登录后自动关闭视图?我假设您的代码如下所示Swift firebase google登录后如何关闭视图,swift,xcode,firebase,Swift,Xcode,Firebase,我有swift 4 firebase谷歌登录的代码。问题是在登录后,它只是将我放回到用于登录的视图上。在哪里执行代码以在登录后自动关闭视图?我假设您的代码如下所示 FIRAuth.auth()?.signIn(withEmail: self.emailTextField.text!, password: self.passwordTextField.text!) { (user, error) in if error == nil {
FIRAuth.auth()?.signIn(withEmail: self.emailTextField.text!, password: self.passwordTextField.text!) { (user, error) in
if error == nil {
//Print into the console if successfully logged in
print("You have successfully logged in")
//Go to the HomeViewController if the login is sucessful
let vc = self.storyboard?.instantiateViewController(withIdentifier: "Home")
self.present(vc!, animated: true, completion: nil)
//If you want to go back to the previous view then call
//For view embedded in navigation controller use,
self.navigationController?.popViewController(animated: true)
//For view that was presented use,
self.dismiss(animated: true, completion: nil)
} else {
//Tells the user that there is an error and then gets firebase to tell them the error
let alertController = UIAlertController(title: "Error", message: error?.localizedDescription, preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
alertController.addAction(defaultAction)
self.present(alertController, animated: true, completion: nil)
}
}
如果您可以发布您在何处执行登录的代码,这将更有帮助。请查看以下两个有关提问的指南:和。没有看到您正在做什么,我们只是猜测,因为答案将取决于您的视图是如何创建的。密码?赛格?IB?还有别的吗?