prevent UIAlertView from dismissing
问题 As a form of validation, is there any way to prevent an alert view from dismissing when pressing an "OK" button? Scenario: I have 2 text fields in the alertview for username/password. If both are empty and the user presses "OK", I do not want the alert to be dismissed. 回答1: iOS 5 introduces a new property to UIAlertView to handle exactly this problem. alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput; Apple documentation on UIAlertView. Add the new UIAlertViewDelegate method to