在UITextfield中輸入ABCD會獲得A B C D這種字母之間的空格須要特殊的方法才能清除掉。php
-(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:@""]; } }
參考連接:html