Skip to content

Instantly share code, notes, and snippets.

@emersonbroga
Created April 27, 2012 13:57
Show Gist options
  • Save emersonbroga/2509498 to your computer and use it in GitHub Desktop.
Save emersonbroga/2509498 to your computer and use it in GitHub Desktop.
Emerson Carvalho.com >> iOS esconder o teclado ao tocar fora do UITextField (snippet 3)
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
//Verifique se o seu textField está com o teclado aberto e se o toque foi fora dele.
if ([myTextField isFirstResponder] && [touch view] != myTextField) {
[myTextField resignFirstResponder];
}
[super touchesBegan:touches withEvent:event];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment