Skip to content

Instantly share code, notes, and snippets.

@johnnyclem
Created January 2, 2014 05:31
Show Gist options
  • Save johnnyclem/8215415 to your computer and use it in GitHub Desktop.
Save johnnyclem/8215415 to your computer and use it in GitHub Desktop.
End the tyranny of UITextFields not resigning first responder when you expect them to, simply add this method to any UIViewController and keyboards will disappear whenever the user touches anywhere other than the keyboard itself or another UITextField
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
for (UIControl *control in self.view.subviews) {
if ([control isKindOfClass:[UITextField class]]) {
[control endEditing:YES];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment