I am giving a textual representation for a tweet of some line.
I use the following method to limit the number of characters to 140.
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{ if([text isEqualToString:@"\b"]){ DLog(@"Ohoooo"); return YES; }else if([[textView text] length] > 140){ return NO; } return YES; }
The code works well, except for the first condition that backspace does not work. Suppose I reach the limit of 140 characters so that the method gives me a lie and the user cannot insert more characters, but after that, when I try to delete some characters, the text view behaves as if it was disabled.
So, the question is how to remove characters from textview.text or re-enable text view.
ios iphone uitextview uitextviewdelegate
harshalb Mar 22 '10 at 12:45 2010-03-22 12:45
source share