5

I have a custom UITextInput-based text editor. It works very well, except for multi-stage input via marked text.

My marked region renders correctly, and marked text is inserted, but the candidate list above the keyboard is blank.

For example, here is the Japanese (Kana) keyboard showing suggestions on a standard UITextView:

Default Marked Text

And here is my custom editor displaying the same marked text:

enter image description here

I have spent several days debugging this issue and have found that the cause is private class UIKeyboardImpl returning NO for the method delegateSupportsCorrectionUI

If I override this method in a category on UIKeyboardImpl and return YES instead, then multistage input suggestions correctly display for my text editor. However this does not address the underlying cause of the problem (and it's not usable).

I have also looked very closely at Apple's SimpleTextInput sample code. This implements a basic Core Text editor. SimpleTextInput correctly displays multistage input suggestions, however I cannot seem to find a single difference in its implementation of UITextInput that causes it to work and mine to break.

(In fact, I am unable to "break" the SimpleTextInput sample's ability to display multi-stage input. Which leads me to think that my focus on the UITextInput implementation is the wrong track. And it is something else altogether.)

simeon
  • 4,466
  • 2
  • 38
  • 42

1 Answers1

4

Okay, this is a bit embarrassing. I just now noticed:

@property(nonatomic, readonly) UIView *textInputView

Discussion

The view that both draws the text and provides a coordinate system for all geometric values in this protocol. (This is typically an instance of the UITextInput-adopting class.) If this property is unimplemented, the first view in the responder chain is selected.

In the documentation.

I had stupidly @synthesize'd this property and forgot about it, meaning my UITextInput implementation was returning a nil textInputView. Simply leaving it unimplemented chooses the first view from the responder chain as described, which provides the text system with the necessary coordinate system to handle auto-correction and multistage input suggestions.

This was after three days of debugging. Now I feel stupid.

simeon
  • 4,466
  • 2
  • 38
  • 42