中文輸入法,輸入驗證碼,字母之間出現空格的解決辦法
阿新 • • 發佈:2018-09-26
http 驗證 中文輸入法 col get html color change china
在UITextfield中輸入ABCD會得到A B C D這種字母之間的空格需要特殊的方法才能清除掉。
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { NSString* newstring = [textField.text stringByReplacingCharactersInRange:range withString:string]; NSString *checker = [NSString stringWithFormat:@"%C", 8198]; // %C為大寫 if ([newstring rangeOfString:checker].length) { newstring = [newstring stringByReplacingOccurrencesOfString:checker withString:@""]; } }
參考鏈接:
http://www.cocoachina.com/bbs/read.php?tid-135439.html
中文輸入法,輸入驗證碼,字母之間出現空格的解決辦法