fix: Input limited the number of words when entering Chinese bug.
This commit is contained in:
parent
35c6d03d14
commit
d412d456bb
@ -38,6 +38,10 @@ function getInput(c: Partial<Input>) {
|
|||||||
inputView.onSubmitEditing = (text) => {
|
inputView.onSubmitEditing = (text) => {
|
||||||
inputed.text = `Submited: ${text}`
|
inputed.text = `Submited: ${text}`
|
||||||
};
|
};
|
||||||
|
inputView.beforeTextChange = (change) => {
|
||||||
|
log(`beforeTextChange ${JSON.stringify(change)}`);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -569,14 +569,16 @@ - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range r
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)textViewDidChange:(UITextView *)textView {
|
- (void)textViewDidChange:(UITextView *)textView {
|
||||||
if (textView.markedTextRange || textView.text.length > 0) {
|
UITextRange *textRange = textView.markedTextRange;
|
||||||
|
if (textRange || textView.text.length > 0) {
|
||||||
self.view.multiLineInput.placeholderLabel.hidden = YES;
|
self.view.multiLineInput.placeholderLabel.hidden = YES;
|
||||||
} else {
|
} else {
|
||||||
self.view.multiLineInput.placeholderLabel.hidden = NO;
|
self.view.multiLineInput.placeholderLabel.hidden = NO;
|
||||||
}
|
}
|
||||||
|
if (textRange) {
|
||||||
if (textView.markedTextRange) return;
|
NSString *text = [textView textInRange:textRange];
|
||||||
|
if (text.length) return;
|
||||||
|
}
|
||||||
if (self.maxLength) {
|
if (self.maxLength) {
|
||||||
UITextRange *range = textView.selectedTextRange;
|
UITextRange *range = textView.selectedTextRange;
|
||||||
textView.text = [self limitToHansMaxLength:self.maxLength.unsignedIntValue text:textView.text];
|
textView.text = [self limitToHansMaxLength:self.maxLength.unsignedIntValue text:textView.text];
|
||||||
@ -612,6 +614,11 @@ - (NSString *)limitToHansMaxLength:(NSUInteger)maxLen text:(NSString *)text {
|
|||||||
|
|
||||||
|
|
||||||
- (void)textFieldDidChange:(UITextField *)textField {
|
- (void)textFieldDidChange:(UITextField *)textField {
|
||||||
|
UITextRange *textRange = textField.markedTextRange;
|
||||||
|
if (textRange) {
|
||||||
|
NSString *text = [textField textInRange:textRange];
|
||||||
|
if (text.length) return;
|
||||||
|
}
|
||||||
if (self.maxLength) {
|
if (self.maxLength) {
|
||||||
UITextRange *range = textField.selectedTextRange;
|
UITextRange *range = textField.selectedTextRange;
|
||||||
textField.text = [self limitToHansMaxLength:self.maxLength.unsignedIntValue text:textField.text];
|
textField.text = [self limitToHansMaxLength:self.maxLength.unsignedIntValue text:textField.text];
|
||||||
|
Reference in New Issue
Block a user