vendredi 1 janvier 2016

performSegueWithIdentifier in if statement isn't working

I have made a funtion for my IBAction with a performSegueWithIdentifier and it worked perfectly fine until now it always shows the alert but it also perform the segue to the next view. I don't know what I have done wrong. The identifier is wright in the MainView. I can't finde any answer to solve this.

@IBOutlet weak var backgroundImageView: UIImageView!
@IBOutlet weak var logInPassword: UITextField!
@IBAction func registerButton(sender: AnyObject) {
}

@IBAction func login(sender: AnyObject) {

    if logInPassword.text!.isEmpty {
        let alertNoPasswordLogIn = UIAlertView()
        alertNoPasswordLogIn.title = "Passwort fehlt"
        alertNoPasswordLogIn.message = "Bitte geben sie ein Passwort ein!"
        alertNoPasswordLogIn.addButtonWithTitle("Ok")
        alertNoPasswordLogIn.show()
    } else {
        self.performSegueWithIdentifier("Login", sender: self)
    }
}

Aucun commentaire:

Enregistrer un commentaire