I do not find a way to hide the keyboard when I touch the keyboard, is there any event that can hide the keyboard if I step out of the keyboard. Thanks
In ViewController.m write that the method started started. In this method write resignFirstResponder
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [textField resignFirstResponder]; }
Here is the best solution that will work for any UITextField in your view controller. You can even add it to your base controller (if you have one) and it will work like a charm.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; if (![[touch view] isKindOfClass:[UITextField class]]) { [self.view endEditing:YES]; } [super touchesBegan:touches withEvent:event]; }
No, you need to do it yourself. The usual approach is to place a transparent button above the screen (but below the text box) and then on the action for the button ...
- (void)dismissPressed:(id)sender { [myTextField resignFirstResponder]; }