实现 UIAlertController 时遇到问题。无法提醒出现
Trouble implementing UIAlertController. Cant get alert to show up
我已将警报设置为在某些用户尝试通过 firebase 请求新密码但无法正常工作时出现任何错误时显示。
正在打印 print("problems with email field")
所以我相信我在编写警告部分时出错了。
@IBAction func recuperarSenha(_ sender: Any) {
Auth.auth().sendPasswordReset(withEmail: self.loginTextView.text!) { error in
if error != nil {
print("problems with email field")
let alert = UIAlertController(title: "Couldn't send recover message", message: "Check if e-mail field is properly filled.", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK!", style: .default, handler: nil))
}
}
}
您需要在创建提醒后展示您的提醒。添加动作后添加如下代码:
self.present(alert, animated: true, completion: nil)
您的代码的编辑版本:
@IBAction func recuperarSenha(_ sender: Any) {
Auth.auth().sendPasswordReset(withEmail: self.loginTextView.text!) { error in
if error != nil {
print("problems with email field")
let alert = UIAlertController(title: "Couldn't send recover message", message: "Check if e-mail field is properly filled.", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK!", style: .default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
}
}
我已将警报设置为在某些用户尝试通过 firebase 请求新密码但无法正常工作时出现任何错误时显示。
正在打印 print("problems with email field")
所以我相信我在编写警告部分时出错了。
@IBAction func recuperarSenha(_ sender: Any) {
Auth.auth().sendPasswordReset(withEmail: self.loginTextView.text!) { error in
if error != nil {
print("problems with email field")
let alert = UIAlertController(title: "Couldn't send recover message", message: "Check if e-mail field is properly filled.", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK!", style: .default, handler: nil))
}
}
}
您需要在创建提醒后展示您的提醒。添加动作后添加如下代码:
self.present(alert, animated: true, completion: nil)
您的代码的编辑版本:
@IBAction func recuperarSenha(_ sender: Any) {
Auth.auth().sendPasswordReset(withEmail: self.loginTextView.text!) { error in
if error != nil {
print("problems with email field")
let alert = UIAlertController(title: "Couldn't send recover message", message: "Check if e-mail field is properly filled.", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK!", style: .default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
}
}