Actually, you are a little confused with the "marked text" and the "candidate text".
Take a Chinese handwriting keyboard, for example, the symbol “修” lies on a note called “marked text,” which has a distinctive style. And “修”, “修改”, “修身”, ... on the keyboard, you can call them “candidates” (the panel in which they were placed is called the “candidate panel” if you check the hierarchy of keyboard representations).
There are some interfaces for working with marked text. You can take a look at the UITextInput protocol, which is confirmed by UITextView and UITextField . -setMarkedText:selectedRange: and -unmarkText will make it difficult.
There is no public API for working on the candidates panel, and how to detect a crane on it is also not documented. But you can indirectly detect this by doing -textView:shouldChangeTextInRange:replacementText: and -textViewDidChange: in the UITextViewDelegate protocol if you use UITextView (or the partner methods for UITextField if you use it).
PS: There is, at least, as I know, an exception for the Chinese keyboard, which seems like an error. When you click on the candidates panel on the Chinese keyboard, the text you use applies to your UITextView (or UITextField ) without -textView:shouldChangeTextInRange:replacementText: But -textViewDidChange: will be called in the end.
Hope this helps.
source share