は表示されません。警告ポップアップは、私は私のプロジェクトでいくつかのコードを持っている
@IBAction func createAccountAction(sender: AnyObject) {
if self.emailField.text == "" || self.passwordField.text == ""
{
let alertController = UIAlertController(title: "Oops!", message: "Please enter an email and password.", preferredStyle: .Alert)
let defaultAction = UIAlertAction(title: "OK", style: .Cancel, handler: nil)
alertController.addAction(defaultAction)
self.presentViewController(alertController, animated: true, completion: nil)
}
else
{
FIRAuth.auth()?.createUserWithEmail(self.emailField.text!, password: self.passwordField.text!) { (user, error) in
if error == nil
{
let alertController = UIAlertController(title: "Done", message: "Account created!", preferredStyle: .Alert)
let defaultAction = UIAlertAction(title: "OK", style: .Cancel, handler: nil)
alertController.addAction(defaultAction)
self.emailField.text = ""
self.passwordField.text = ""
}
else
{
let alertController = UIAlertController(title: "Oops!", message: error?.localizedDescription, preferredStyle: .Alert)
let defaultAction = UIAlertAction(title: "OK", style: .Cancel, handler: nil)
alertController.addAction(defaultAction)
self.presentViewController(alertController, animated: true, completion: nil)
}
あなたは私がcreateAccountActionをクリックしたときに表示されるメッセージOops
でalertControllerを持って、最後のelseステートメントで見ることができるようにボタン。
しかし、ユーザーがボタンを押して、テキストフィールドに何も入力していない場合に起こります。
私が望むのは、ユーザーがテキストフィールドを正常に入力すると、指定した他のテキストとともに同じポップアップが表示されることです。
私はそれが一部
self.emailField.text = ""
self.passwordField.text = ""
を行いますがAlertControllerを提示していないコードを実行します。
私は何をしたいのですか?
ありがとうございます!それはそれを修正する...深夜コーディングは、あなたがそのような小さなシンプルなものを監督する原因になります..:P – matthewdossantos
あなたは私の答えに満足している場合は、チャンスを持っているときに横のチェックをクリックしてください。 – WMios
10分後に一度やります:) – matthewdossantos