From cb9f377a9051575884ca1018a1b33a9fd29de96b Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Fri, 8 May 2020 15:51:00 +0800 Subject: [PATCH] iOS:fix emoji cause substring error --- doric-iOS/Pod/Classes/Shader/DoricInputNode.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doric-iOS/Pod/Classes/Shader/DoricInputNode.m b/doric-iOS/Pod/Classes/Shader/DoricInputNode.m index 7b02cb13..75954e76 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricInputNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricInputNode.m @@ -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) {