I'm building a custom keyboard
and I'm implementing the following delegate methods in my InputViewController
.
But I always get _textInput = nil_
- (void)textWillChange:(id<UITextInput>)textInput
- (void)textDidChange:(id<UITextInput>)textInput
- (void) selectionWillChange:(id<UITextInput>)textInput
- (void) selectionDidChange:(id<UITextInput>)textInput
Does anybody know how to fix it?
Is it nil
for a reason?
Do I need to implement something by myself?
Good question. But it seems that
UITextInputDelegate
is not a protocol that you implement.From Apple Docs titled Lower Level Text-Handling Technologies:
And from the docs on UITextInputDelegate:
The implication of the above is that we don't implement these delegate methods; we use them to inform the
inputDelegate
that you have changed your text or selection via means other than keyboard input.Here is an example method that illustrates this:
Sample code with more examples here.