开发者

UITextField shouldChangeCharactersInRange stops getting called if I press backspace for a long time

If I type开发者_StackOverflow 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜