I have a UITextView, the size of which is set through setFrame:CGRectMake(30, 100, 273, 140).
I would like to prevent inserting text that exceeds the size of the TextView.
So I’ve tried :
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
if ((textView.contentOffset.y + textView.frame.size.height) < textView.contentSize.height){
return NO;
}
else {
return YES;
}
return YES;
}
The pb is that when the condition is met, I can’t use backspace to erase the extra text. The textview is no longer editable. What am I doing wrong here ?
Thanks for your help.
Ok, I think I’ve found out by myself this time.
I don’t know if it is the best solution but it works fine at least.
Hope it may help someone…
Mike