iOS: code optimize,delete useless code

This commit is contained in:
pengfei.zhou 2021-06-08 18:20:37 +08:00 committed by osborn
parent 23a39f20fc
commit d834336b3c

View File

@ -228,13 +228,9 @@ - (BOOL)textViewShouldEndEditing:(UITextView *)textView {
- (void)textViewDidChange:(UITextView *)textView { - (void)textViewDidChange:(UITextView *)textView {
if (textView.markedTextRange) return; if (textView.markedTextRange) return;
if (self.maxLength) { if (self.maxLength) {
UITextRange *selectedRange = [textView markedTextRange]; textView.text = [self limitToHansMaxLength:self.maxLength.unsignedIntValue text:textView.text];
UITextPosition *pos = [textView positionFromPosition:selectedRange.start offset:0];
if (!pos) {
textView.text = [self limitToHansMaxLength:self.maxLength.unsignedIntValue text:textView.text];
}
} }
if (self.onTextChange) { if (self.onTextChange) {
self.onTextChange(textView.text, self); self.onTextChange(textView.text, self);