2012-07-27 22 views
5

He usado inputView para mostrar uipickerview para mi textfield, pero uso el mismo textfield para otras funciones. ¿Cómo puedo mostrar el teclado estándar después de haber usado inputView para ese textfield?Cómo mostrar el teclado después de utilizar inputView

textfield.inputView = pickrView; 
+0

textfield.inputView = NO; trabajado para mí –

Respuesta

10

Sólo

textfield.inputView = nil;

trabajó para mí

+1

es mejor que uses nulo o NULO en lugar de NO. La propiedad inputView espera un UIView y no un BOOL. Aunque esto funciona con NO como cero y NO son ambos un 0 numérico, esto fallará y se bloqueará si asigna SÍ. –

+0

Ok ... ¡gracias! –

+3

no funciona conmigo :( – HusseinB

0

creo que este código tal vez puede trabajar

[textField.inputView addTarget:self action:@selector(doTest) forControlEvents:UIControlEventTouchUpInside]; 

- (void)doTest 
{ 
    if([textFiled isFirstResponder]) 
    { 
    [textFiled resignFirstResponder]; 
    } 
    else 
    { 
    [textFiled becomeFirstResponder]; 
    } 
} 
3

Como dijo Pavel Kaljunen, sólo es necesario para establecer el inputView a cero, pero cuando el teclado ya está visible, debe resignFirstR primero, establezca inputView en nil y luego se convierta en FirstResponder nuevamente.

[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:0.35]; 

[yourTextField resignFirstResponder]; 
yourTextField.inputView = nil; 
[yourTextField becomeFirstResponder]; 

[UIView commitAnimations]; 
Cuestiones relacionadas