1

If I type a very long text in my UITextField, for example: 123456789012345678901234567890.

Now if I press the backspace and leave it pressed, then the shouldChangeCharactersInRange is called for some characters in the beginning.

But, then when the UITextField start getting cleared with a fast speed, the shouldChangeCharactersInRange stops getting called. Can anyone suggest me a solution.

Pria
  • 2,743
  • 4
  • 27
  • 30

1 Answers1

1

You can add observer for the UITextFieldTextDidChangeNotification which will be posted whenever the text changes in text field.

[[NSNotificationCenter defaultCenter] 
     addObserver:self 
     selector:@selector(yourMethod:)
     name:UITextFieldTextDidChangeNotification 
     object:yourTextField];

In this case, yourMethod: method will always work.