Ocultar teclado iPhone


/ Published in: iPhone
Save to your folder(s)

Oculta el teclado del iPhone cuando se toca en otro lado de la pantalla que no sea el campo de texto actual.


Copy this code and paste it in your HTML
  1. // Esta funcion es para que cuando el Usuario toque fuera de
  2. // un campo de texto, desaparezca el teclado
  3.  
  4. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
  5.  
  6. UITouch *touch = [[event allTouches] anyObject];
  7.  
  8. // Listo los campos de texto
  9. if ([txtUsuario isFirstResponder] && [touch view] != txtUsuario) {
  10. [txtUsuario resignFirstResponder];
  11. }
  12.  
  13. if ([txtPassword isFirstResponder] && [touch view] != txtPassword) {
  14. [txtPassword resignFirstResponder];
  15. }
  16. [super touchesBegan:touches withEvent:event];
  17. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.