apache / incubator-weex

Apache Weex (Incubating)
https://weex.apache.org
Apache License 2.0
13.75k stars 1.82k forks source link

[iOS] input标签当type="tel"或者type = "numuber"时候,无法进行剪切(只有选择一个字符时候是可以剪切) #2913

Open Zss1990 opened 4 years ago

Zss1990 commented 4 years ago

[iOS] input标签当type="tel"或者type = "numuber"时候,无法进行剪切(只有选择一个字符时候是可以剪切) 发现了这段代码

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    if (!string.length) {
        ((WXTextInputView*)textField).deleteWords = YES;
        ((WXTextInputView*)textField).editWords = [textField.text substringWithRange:range];
    } else {
        ((WXTextInputView*)textField).deleteWords = FALSE;
        ((WXTextInputView*)textField).editWords = string;
    }

    if ([_inputType isEqualToString:@"tel"] || [_inputType isEqualToString:@"number"] ) {
        if (![self isPureInt:string]) {
            if ([string isEqualToString:@"+"]||[string isEqualToString:@"."]||[string isEqualToString:@"*"]||[string isEqualToString:@"#"]||(string.length == 0 && range.length == 1))
            {
                return YES;
            }
            return NO;
        }
    }
    return YES;
}

其中(string.length == 0 && range.length == 1) 才允许剪切,是否是一个bug?

YorkShen commented 4 years ago

Great work, it seems like you already find the answer.

You could give us a PR if you can, I am very happy to talk with you implemenation detail or review you PR in mailing list.

As I have a busy schedule, I may read Github issuse months later, but I check mailing list everyday.