Skip to content

Instantly share code, notes, and snippets.

@jacoblyles
Created November 19, 2010 03:12
Show Gist options
  • Save jacoblyles/706078 to your computer and use it in GitHub Desktop.
Save jacoblyles/706078 to your computer and use it in GitHub Desktop.
Method to hide keyboard when background tapped
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
for (UITouch *touch in touches){
if (touch.view == self.view){
[self findAndResignFirstResponder];
}
}
}
-(void)findAndResignFirstResponder{
for (UIView *aView in [self.view subviews]){
if ([aView isFirstResponder] ) {
[aView resignFirstResponder];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment