By default the Number Pad keyboard unlike the default keyboard does not have a “Done” button. I tried a number of different techniques to dismiss the keyboard, e.g., set the UITextField’s delegate to the ViewController and then add this method:
- (void)textFieldDidEndEditing:(UITextField *)textField { [textField resignFirstResponder]; }
But this didn’t work. The method would get called, but the focus still remained in the UITextField. Instead, I chose to use the touches
methods to dismiss the keyboard. This allows the user to touch anywhere outside of the text field to dismiss the keyboard. Here is a method that will dismiss the keyboard:
-(void)touchesBegan: (NSSet *)touches withEvent:(UIEvent *)event { // do the following for all textfields in your current view [self.my_text_field_1 resignFirstResponder]; // save the value of the textfield, ... }
November 26, 2011 at 9:18 pm |
Thanks for this post, REALLY helped!
Bless you!
December 6, 2013 at 4:37 pm |
Thanks, worked great!