Hide keyboard on touch outside of textfield
问题 I'm trying to hide the keyboard after a touch anywhere else on the screen. The code I'm using is based on this answer here. IBOutlet UITextView *myTextView; And the method: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; if ([myTextView isFirstResponder] && [touch view] != myTextView) { [myTextView resignFirstResponder]; } [super touchesBegan:touches withEvent:event]; } What I don't understand is how I should link my