ioscocoa-touchuitextinput

UITextInput: reset multi stage input suggestions


In my app I have implemented UITextInput to handle multi stage text input for my custom UITextField. I was wondering if anyone knows how to reset the multi stage input suggestions that appear above the keyboard when typing on the Japanese keyboard:

enter image description here

I'm just wanting to clear out the marked text and reset everything. The only way to do this right now is if the user manually presses the return key or dismisses the UITextView.

Is there any way to do this in the code? In looking at the documentation for UITextInput, it's not obvious.


Solution

  • This can be accomplished by doing the following:

    [self.inputDelegate selectionWillChange:self];
    self.selectedTextRange = NSMakeRange(self.cursor.position, 0);
    self.markedTextRange = NSMakeRange(NSNotFound, 0);
    [self.inputDelegate selectionDidChange:self];