Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Please help me fix this issue.

In iOS7, I set the UITextField alignment right. But when I input space as a first character in the text field. The cursor automatically move to left side of the text field as if the textfield is left-aligned.

This issue does not happen in iOS5, iOS6.

like image 952
Tuyen Nguyen Avatar asked Oct 07 '13 07:10

Tuyen Nguyen


1 Answers

I am assuming you don't wanna allow the user to enter space as the first character. If that's true this solution would work.

Wire your editing changed event of UITextField to this method.

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

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


}
like image 74
ManicMonkOnMac Avatar answered Nov 15 '22 04:11

ManicMonkOnMac