只有正确输入用户名和密码,才能尝试使此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"
}
}