2

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.

sridevi
  • 617
  • 1
  • 6
  • 15

1 Answers1

0

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

Kirsteins
  • 27,065
  • 8
  • 76
  • 78
  • I tried using UITextInput protocol but still the insertText: method is not called. I want to create a generic UITextField's subclass that can control the character entry in itself. And I want to leave the flexibility for other classes to assign the delegate of the UITextField's subclass object to any object they want. – sridevi Aug 29 '13 at 20:42