I have custom keyboard extension with UITextField in it. I am able switch to UITextField's text input, but cannot switch back to self.textDocumentProxy. Does anybody know, how to do something like [self.textDocumentProxy becomeFirstResponder]?
(By the way, it looks like "GIF Keyboard" app provides such possibility)
I've implemented next workaround for this:
My
textFiedinherits fromUITextField.UserInteractiondisabled to prevent it frombecomeFirstResponder(because you are not able switch back to system input). I've added blinkingUIViewas cursor imitation (blinking animation). Change this cursororigin.xin overwritedsetText:method by calculating length of current string (useboundingRectWithSize:method for this).When user types something I am checking if
textFieldis active (showed) and then adding/removing symbols totextField(withsetText:) orself.textDocumentProxyinsertText:/deleteBackwardmethods accordingly.
来源:https://stackoverflow.com/questions/34420344/custom-keyboard-extension-with-uitextfield