To cancel the keyboard when the user clicks the Warning button in the corresponding notification delegation method
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
do the following:
[myTextField resignFirstResponder]
To programmatically refuse to view alerts, use this:
- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated
Then you use the same code in clickedButtonAtIndex: for resignFirstResponder to cancel the keyboard.
source
share