Ios 从FIREBASE_REF块内快速关闭vc控制器
我只是在寻找帮助,关闭createuser vc并返回到以前的初始vc(如果firebase中已经存在用户) 我目前有:Ios 从FIREBASE_REF块内快速关闭vc控制器,ios,swift,firebase,Ios,Swift,Firebase,我只是在寻找帮助,关闭createuser vc并返回到以前的初始vc(如果firebase中已经存在用户) 我目前有: // Attempt to create a new user. (authData = dictionary). FIREBASE_REF.createUser(email, password: password, withValueCompletionBlock: { (error, authData) in // If there was no er
// Attempt to create a new user. (authData = dictionary).
FIREBASE_REF.createUser(email, password: password, withValueCompletionBlock: { (error, authData) in
// If there was no error then
if error == nil {
// Authorise the new user into the application. (authData = object).
FIREBASE_REF.authUser(email, password: password, withCompletionBlock: { ( error, authData) in
if error == nil {
// Store the user id into the device.
NSUserDefaults.standardUserDefaults().setValue(authData.uid, forKey: "uid")
// Stop the activity indicator.
self.activityInd.stopAnimating()
// Close the create user screen.
self.dismissViewControllerAnimated(true, completion: nil)
}
else
{
// Stop the activity indicator.
self.activityInd.stopAnimating()
print(error)
}
})
}
else
// USER ACCOUNT ALREADY EXISTS \\
{
// Stop the activity indicator.
self.activityInd.stopAnimating()
// Display an error message.
let alertController = UIAlertController(title: "USER DUPLICATION ERROR", message:
"user account already exists, login as normal", preferredStyle: UIAlertControllerStyle.Alert)
alertController.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.Default,handler: nil))
self.presentViewController(alertController, animated: true, completion: nil)
// Close the create user screen.
self.dismissViewControllerAnimated(true, completion: nil)
}
})
当用户创建一个新帐户时,self.dismissViewController工作正常,返回初始vc,然后加载主页。但是,当已有用户时,self.dismissViewController不会执行任何操作。如果有人能对此有所了解,我们将不胜感激
此外,如果有人能建议如何确保警报消息在用户选择关闭vc之前一直显示在屏幕上,这也会很有帮助
谢谢问题解决了,如果有人感兴趣,以下是我如何解决这个问题的:
// USER ACCOUNT ALREADY EXISTS \\
{
// Stop the activity indicator.
self.activityInd.stopAnimating()
// Display an error message.
let refreshAlert = UIAlertController(title: "USER DUPLICATION ERROR", message: "user account already exists, login as normal.", preferredStyle: UIAlertControllerStyle.Alert)
refreshAlert.addAction(UIAlertAction(title: "Dismiss", style: .Default, handler: { (action: UIAlertAction!) in
// Close the create user screen.
self.dismissViewControllerAnimated(true, completion: nil)
}))
self.presentViewController(refreshAlert, animated: true, completion: nil)
}
})
我已经缩小了范围,当我注释掉警报消息时,它会关闭屏幕并按其应该的方式返回。显然,警报消息导致了问题,如果有人能告诉我为什么会导致问题,我将不胜感激。我怀疑一旦调用了警报,它就不再在代码中继续。