UITextView 输入长度限制
//还可以输入的长度。 - (void)textViewDidChange:(UITextView *)textView { UITextRange *markRange = textView.markedTextRange; int pos = [textView offsetFromPosition:markRange.start toPosition:markRange.end]; int nLength = textView.text.length - pos; if (nLength > 15 && pos == 0) { _limit.text = [NSString stringWithFormat:@"%d/%@",15,@"15"]; _nickTextView.text = [textView.text substringToIndex:15]; } else if(nLength <= 15 && pos == 0) { _limit.text = [NSString stringWithFormat:@"%d/%@",[textView.text length],@"15"]; } }