Actually, you are kind of confused with the "marked text" and the "candidate text".
Take the Chinese-Handwriting keyboard for instance, the symbol "修" lies on the note is called "marked text", which has a distinctive style. And the "修", "修改", "修身", ... on the keyboard, you can call them "candidates"(The bar where they placed is named "candidate bar", if you inspect the view hierarchy of the keyboard).
There are some interfaces to operate on marked text. You could take a look at UITextInput
protocol which UITextView
and UITextField
are confirmed to. -setMarkedText:selectedRange:
and -unmarkText
will do the tricky.
There is no public API to operate on the candidate bar and how to detect the tap on it is undocumented as well. But you can indirectly detect that by implementing -textView:shouldChangeTextInRange:replacementText:
and -textViewDidChange:
in UITextViewDelegate
protocol if you are using UITextView
(or the counterpart methods for UITextField
if you are using it).
P.S: There is, at least, as I know, an exception for the Chinese keyboard, which is kind of like a bug. When you tap the candidate bar of a Chinese keyboard, the text you tapped is applied to your UITextView
(or UITextField
) without -textView:shouldChangeTextInRange:replacementText:
triggered. But -textViewDidChange:
will be invoked eventually.
Hope it could help.