IF条件下的IOS segue不起作用

时间:2017-01-23 05:24:19

标签: ios swift cocoa-touch if-statement segue

只有正确输入用户名和密码,才能尝试使此segue运行。

但即使我输错了它,它会显示消息并仍然运行segue?我该如何解决这个问题?

@IBAction func login(_ sender: Any) {
    if (username.text == "username" && password.text == "password") {
        print("you may login")
        performSegue(withIdentifier: "login", sender: self)
        let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
        let viewController = storyBoard.instantiateViewController(withIdentifier: "admin") as! admin
        viewController.msgtxt = username.text!
        self.present(viewController, animated: true, completion: nil)
    } else if (username.text != "username" && password.text != "password"){ 
        loginMsg.text = "incorrect username and/or password"
    } 
}

0 个答案:

没有答案