【发布时间】:2020-06-18 12:09:20
【问题描述】:
我为我的应用创建了登录和注册页面。一切运行顺利,但我希望能够在用户输入错误的电子邮件地址或密码时自定义错误消息。这是我现在的代码:
// Signing in the user
Auth.auth().signIn(withEmail: email, password: password) { (result, error) in
if error != nil {
// Couldn't sign in
self.loginErrorLabel.text = error!.localizedDescription
self.loginErrorLabel.alpha = 1
}
else {
let homeViewController = self.storyboard?.instantiateViewController(identifier: Constants.Storyboard.homeViewController) as? HomeViewController
self.view.window?.rootViewController = homeViewController
self.view.window?.makeKeyAndVisible()
}
}
当用户输入不存在/不正确的电子邮件或密码时,会出现错误标签,提示“密码无效或用户没有密码。”
相反,我希望它返回:“您输入的用户名或密码不正确。” 有没有办法在不完全更改代码的情况下做到这一点,例如只预先添加一些代码来指示localizedDescription 是什么?欢迎大家帮忙,非常感谢!
【问题讨论】:
标签: swift xcode customization message