2010-10-04 114 views
37

有没有办法以编程方式隐藏UIAlertView?实际上,我在UIAlertView中添加了一个UITextField,并且当用户敲击键盘返回键时,我想要执行与“Ok”按钮按下相同的操作。以编程方式隐藏UIAlertView?

回答

81

呼叫

[theAlertView dismissWithClickedButtonIndex:0 animated:YES]; 
当你处理返回键

+1

谢谢你。如果你想让它更灵活一些,你也可以说'[theAlertView dismissWithClickedButtonIndex:theAlertView.cancelButtonIndex animated:YES];''或'[theAlertView dismissWithClickedButtonIndex:theAlertView.firstOtherButtonIndex animated:YES];'点击第一个不取消按钮。 – palme 2013-11-22 09:40:33

相关问题