I've made a validation that a user can't login if both text field is blank. However, the alert message is popped out but it still will navigate to the next controller. How to overcome this problem? This exists while both text field is blank and just only showing the alert message, not navigating to next controller?
I'm assuming you have a segue from the Login button to the next scene. So what you'll want to do is implement
override func shouldPerformSegueWithIdentifier(identifier: String?, sender: AnyObject?) -> Bool
then check if the identifier is equal to the segue identifier from the Login button.
I would move your validation into this method and return false if the validation fails, otherwise true.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.