Created
January 2, 2014 05:31
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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