Evitar que el teclado aparezca con un campo de texto como primera respuesta

I do a new post because I have a problem that I can't find the respons on the internet. I'm working with a bluetooth barcoder with a clean view without any viewable textfields. To catch the information of the barcoder I use a hidden textfield and works fine. The problem is when the Barcoder disconnects it appears the keyboard because a field is the first responder. I don't want to resign that field but I don't want the keyboard appears.

I have a function that catch when the keyboard will appear:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector (keyboardWillShow:) name: UIKeyboardWillShowNotification object:nil];

What I want is to stop the event of the keyboard or if not's possible hide it when appears. Any ideas about it? Any help will very usefull...

¡Gracias chicos!

preguntado el 02 de febrero de 12 a las 11:02

It's solved! I have made an blank input view so no keyboard appears: ' [_textSender setInputView:[[UIView alloc] init]];' I hope it help to someone! -

2 Respuestas

Dhilip's answer may work for you. If it doesn't here are some alternatives:

1) set the textField.enabled property to NO.

2) Subclass UITextField and return nil for the inputView:

@interface MyTextField: UITextField

@end

@implementation MyTextField

- (void)inputView
{
    return nil;
}

@end

If you use your custom textfield class instead of a regular UITextField, it works the same except that you've said to use nil for it's keyboard instead of UIKeyboardView (which is the default).

Respondido 02 Feb 12, 20:02

I cannot understand your question properly, but still i got a suggestion for you.

If you are setting the text in UITextField programmatically, you can set userInteractionEnabled property to No.

Respondido 02 Feb 12, 17:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.