In my iPad app, I noticed different behavior between iOS 6 and iOS 7 with UITextFields.
I create the UITextField as follows:
UIButton *theButton = (UIButton*)sender;
UITextField *textField = [[UITextField alloc] initWithFrame:[theButton frame]];
[textField setDelegate:self];
[textField setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
[textField setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
textField.textAlignment = UITextAlignmentRight;
textField.keyboardType = UIKeyboardTypeDefault;
...
[textField becomeFirstResponder];
In iOS 6, when I type "hello world" the cursor advances a blank space when I hit the spacebar after "hello."
In iOS 7, the cursor does not advance when I hit the spacebar. However, when I type the "w" in "world," it shows the space and the w.
How can I advance the cursor when the spacebar is hit in iOS 7?
Update:
If I change the textField.textAlignment to UITextAlignmentLeft, then the space appears in iOS 7. I would like to keep it right aligned, if possible.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…