UITextfield subclass not responding to insertText: method of UIKeyInput protocol

1k Views Asked by At

I want to observe the text input in a UITextfield subclass. For that I m trying to implement UIKeyInput protocol methods in that subclass. But the insertText: and hasText methods are never called. However deleteBackward method is called. Do you know why these methods are not called. When I test the same scenario with UIView subclass I have seen that all the methods in UIKeyInput protocol are called.

If this does not work is there any other way to notice the text input in a UITextField subclass?

I know about the UITextFieldDelegate's - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string method. But I want to control the character entry in the UITextField's subclass and not by its delegate.

1

There are 1 best solutions below

1
Kirsteins On

It seems UITextField is using UITextInput protocol for this functionality. Perhaps you can use UITextField to be delegate of itself.