草庐IT

ios - 在 iOS7 : The cursor of right-aligned UITextField automatically moves to left side when input space

coder 2023-09-22 原文

请帮我解决这个问题。

在 iOS7 中,我将 UITextField 对齐设置为正确。 但是当我在文本字段中输入空格作为第一个字符时。光标自动移动到文本字段的左侧,就像文本字段左对齐一样。

iOS5、iOS6不会出现此问题。

最佳答案

我假设您不想让用户输入空格作为第一个字符。如果这是真的,那么这个解决方案就可行了。

将 UITextField 的编辑更改事件连接到此方法。

- (void)removeSpace : (UITextField *)sender{

    if ([sender.text  isEqual: @" "]) {
        sender.text = @"";
    }


}

关于ios - 在 iOS7 : The cursor of right-aligned UITextField automatically moves to left side when input space,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19219487/

有关ios - 在 iOS7 : The cursor of right-aligned UITextField automatically moves to left side when input space的更多相关文章

随机推荐