prevent UIAlertView from dismissing

后端 未结 3 1242
梦如初夏
梦如初夏 2021-01-11 22:37

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 fo

3条回答
  •  别那么骄傲
    2021-01-11 23:23

    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 handle the enabling/disabling of the button.

    - (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView
    

    Apple documentation on UIAlertViewDelegate.

提交回复
热议问题