I want to show the characters number when I type in a UITextView. But I'm confused when I presse the delete/backspace key.
I use:
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
My code is:
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
NSLog(@"input %d chars",textView.text.length + 1);
return YES;
}
When I type in hello, it shows 'input 5 chars'; But if I click the delete/backspace key, the number become 6, not 4. What's the matter with this? How I can know the exact number of chars in the UITextView when I type in?