I setup my UITextfield to be
NSTextAlignmentRight
,and it's cursor is at the right end as normal.
When I entered a space the cursor go to the left end of UITextfield.
I try to fix this problem by implement
UITextFieldDelegate
method
like this:
#pragma mark - UITextFieldDelegate
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if (range.location == 0 && [string isEqualToString:@" "]) {
return NO;
}
return YES;
}
But it's a bit of a mess,and I can't input space for the first character.
Is there a better solution to fix this?
Why this bug happens?