iOS:fix emoji cause substring error

This commit is contained in:
pengfei.zhou 2020-05-08 15:51:00 +08:00 committed by osborn
parent 7828b24cd5
commit cb9f377a90

View File

@ -199,7 +199,8 @@ - (BOOL)textViewShouldEndEditing:(UITextView *)textView {
- (void)textViewDidChange:(UITextView *)textView {
if (self.maxLength) {
if (textView.text.length > self.maxLength.unsignedIntValue) {
textView.text = [textView.text substringToIndex:self.maxLength.unsignedIntValue];
NSRange range = [textView.text rangeOfComposedCharacterSequencesForRange:NSMakeRange(0, self.maxLength.unsignedIntValue)];
textView.text = [textView.text substringWithRange:range];
}
}
if (self.onTextChange) {