任何人都可以帮助我防止在其按钮单击事件上解雇警报视图吗?
我有一个 textview 作为我的alertView 的子视图,如果 textview 值为 nil,我不想关闭它。
因为这是一个非常老的问题,但我得到了一个解决方案,并且如果其他开发人员在不久的将来需要的话,我会发布。
在.h文件中实现协议方法
为了响应 UIAlertView 中的按钮点击,我们将使用 –alertView:clickedButtonAtIndex: 协议方法
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
}
//Now below code will check if uitextfield value.
- (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView
{
NSString *inputText = [[alertView textFieldAtIndex:0] text];
if( [inputText length] > 0)
{
//text field value is greater than zero ,then Done button will appear as blue,or else it will be blurred
return YES;
}
else
{
return NO;
}
}
或者,还有一种更快的方法:
return [inputText length] ? YES : NO;
与 做同样的事情if statement
does.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)