User keyboard: select highlighted text

From mine, Custom KeyboardI would like to know if the user has selected something in his text (and its range). After the documentation, I thought that I could use the callbacks provided by the protocol UITextInputDelegate:

  • selectionWillChange (textInput: UITextInput)
  • selectionDidChange (textInput: UITextInput)
  • textWillChange (textInput: UITextInput)
  • textDidChange (textInput: UITextInput)

However, callbacks are selectionWill/DidChangenever called. If I change the selection in the text, other callbacks will be activated ( textWill/DidChange). Since this is already odd, the problem is that the parameter is textInputalways zero. But I need this, because I would like to get access to selectedTextRangesolve my problem.

Any ideas how to extract the selected text and / or its range within a custom keyboard implementation?

+4
source share
1 answer

If I'm not completely mistaken, this is impossible. (You mean your own keyboard app on iOS 8, not embedding your own keyboard in your app, right?)

Your keyboard does not have access to the text actually written by the user, because the UITextView is in a completely different application.

: https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/Keyboard.html - " ", 7

UIInputViewController, . , . (, , ), . .


: IB? UITextInputDelegate ( ?) ? ... ;)

+4

All Articles