防止关闭UIAlertView [英] prevent UIAlertView from dismissing
本文介绍了防止关闭UIAlertView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
作为一种验证形式,是否有任何方法可以防止在按下确定"按钮时关闭警报视图?
As a form of validation, is there any way to prevent an alert view from dismissing when pressing an "OK" button?
方案:我在Alertview中有2个文本字段,用于输入用户名/密码.如果两者都为空并且用户按下确定",则我不希望该警报被取消.
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.
推荐答案
iOS 5为UIAlertView
引入了一个新属性来精确地解决此问题.
iOS 5 introduces a new property to UIAlertView
to handle exactly this problem.
alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
添加新的UIAlertViewDelegate
方法来处理按钮的启用/禁用.
Add the new UIAlertViewDelegate
method to handle the enabling/disabling of the button.
- (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView
这篇关于防止关闭UIAlertView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文