api*_*nho 13 uitextfield ios ios7
我有一个问题,当在iOS7上右对齐UITextField时,当用户键入"Space"时,它不会马上出现.如果我输入另一个字符,则会出现空格.
在iOS 6中确实没有发生
有人知道怎么修这个东西吗?
Aks*_*eri 14
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if (range.location == textField.text.length && [string isEqualToString:@" "]) {
// ignore replacement string and add your own
textField.text = [textField.text stringByAppendingString:@"\u00a0"];
return NO;
}
// for all other cases, proceed with replacement
return YES;
}
Run Code Online (Sandbox Code Playgroud)
从文本中删除代码
self.txtFirstName.text = [self.txtFirstName.text stringByReplacingOccurrencesOfString:@"\u00a0" withString:@" "];
Run Code Online (Sandbox Code Playgroud)
FROM此stackoverflow答案 - 右对齐的UITextField空格键不会在iOS 7中前进光标
| 归档时间: |
|
| 查看次数: |
3478 次 |
| 最近记录: |