2012-02-02 10 views
7

Tengo un UITextView que recibe entrada desde el teclado. La casilla de verificación "Activar activación de la tecla Volver" está marcada, por lo tanto, cuando el UITextView está vacío, la tecla Volver está desactivada.¿Cómo puedo activar o desactivar manualmente la tecla Retorno en el teclado?

Tengo una barra de emoticones encima del teclado que también puede agregar emoticones al UITextView, pero este es el problema; Cuando el UITextView está vacío y puedo añadir un emoticono al UITextView así:

[inputTextView insertText:@"\ue40d"]; 

entonces el ReturnKey se continúa incapacitado, aunque la propiedad text del UITextView no está vacío.

He intentado esto después de insertar un emoticono:

[inputTextView setEnablesReturnKeyAutomatically:NO]; 

sin resultados. Parece que habilitar/deshabilitar la tecla de retorno del teclado solo se activa al ingresar caracteres a través del teclado.

¿Alguna idea es cómo activar/desactivar manualmente la tecla Volver?

+0

lo hace funcionar como está previsto si escribe el texto normal ¿en ello? –

Respuesta

2

Es un poco de un truco, pero se puede tratar de insertar el texto a través de la mesa de trabajo en su lugar:

UIPasteboard* generalPasteboard = [UIPasteboard generalPasteboard]; 

// Save a copy of the system pasteboard's items 
// so we can restore them later. 
NSArray* items = [generalPasteboard.items copy]; 

// Set the contents of the system pasteboard 
// to the text we wish to insert. 
generalPasteboard.string = text; 

// Tell this responder to paste the contents of the 
// system pasteboard at the current cursor location. 
[textfield paste: nil]; 

// Restore the system pasteboard to its original items. 
generalPasteboard.items = items; 

// Free the items array we copied earlier. 
[items release]; 
-1

desmarque "Activar automáticamente Tecla Return"

+1

Esto lo habilita todo el tiempo ... – GreenKiwi

Cuestiones relacionadas