Custom Keyboard Extension with UITextField

I have a custom keyboard extension with UITextField. I can switch to UITextField text input, but cannot return to self.textDocumentProxy . Does anyone know how to do something like [self.textDocumentProxy becomeFirstResponder] ?

(By the way, it seems that GIF Keyboard application provides such an opportunity)

+4
ios uitextfield custom-keyboard textdocumentproxy
source share
1 answer

I applied the following workaround for this:

  • My textFied inherits from UITextField . UserInteraction disabled to prevent it from becomeFirstResponder (because you cannot return to system input). I added flashing UIView as a simulation of a cursor ( blinking animation ). Change this cursor origin.x to the rewritten setText: method, calculating the length of the current line (use the boundingRectWithSize: method for this).

  • When the user enters something, I check if textField active (shown) and then the character is added / removed to textField (with setText: or self.textDocumentProxy insertText: / deleteBackward methods, respectively.

+3
source share

All Articles