Is there a way to hide UIAlertView programmatically? Actually I have added a UITextField in UIAlertView and I want to perform the same operation as on "Ok" button press when a user hits the keyboard return key.
Asked
Active
Viewed 2.1k times
1 Answers
81
Call
[theAlertView dismissWithClickedButtonIndex:0 animated:YES];
when you handle the return key.
kennytm
- 491,404
- 99
- 1,053
- 989
-
1Thanks for this. If you want it a little more flexible you could also say `[theAlertView dismissWithClickedButtonIndex: theAlertView.cancelButtonIndex animated:YES];` or `[theAlertView dismissWithClickedButtonIndex: theAlertView.firstOtherButtonIndex animated:YES];` to click the first not cancel button. – palme Nov 22 '13 at 09:40