标签:
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
CGFloat textHeight = textView.contentSize.height;
NSLog(@"%@",[NSString stringWithFormat:@"%f",textHeight]);
if (range.location>250 )
{
_textView.text = [_textView.text substringToIndex:5];
[MBProgressHUD showError:@"最多只能输入250个字"];
return NO;
}else if (textView.contentSize.height >= 127){//正好是最8行,这里的127是根据textView.contentSize.height动态计算出来的
[MBProgressHUD showError:@"最多只能输入8行"];
textView.text = [textView.text substringToIndex:[textView.text length]-1];
return NO;
}
else
{
return YES;
}
}
标签:
原文地址:http://www.cnblogs.com/TheYouth/p/4951783.html