UITextField placeholder text position wrong when right aligned and orientation changed
I'm not sure if I've found a bug or missing some intricate setting in the iOS SDK.
I have a UITextField with right aligned text and some placeholder text. I've set it to autosize when switching from portrait to landscape (IB settings are like this: http://db.tt/laTmXIS ).
When in Portrait, it all works as expected: http://db.tt/skf8wqN However, after rotating the placeholder text is in the wrong place: http://db.tt/7pU5kdR
It looks to me that the autoresizing properties are not replicated into the placeholder text UILabel subview.
I've replicated this in a new project (download here: http://db.tt/OSnvv2Y), so it's nothing funky in my code as far as I can see.
Any ideas?
Update: Dan's workaround fixes this. Add an IBOutlet connected to your textField and then add this code to your UIViewController
...
- (void)didRotateFromInterfaceOrientation:
(UIInterfaceOrientation)fromInterfaceOrientation {
textField.textAlignmen开发者_如何学Ct = UITextAlignmentLeft;
textField.textAlignment = UITextAlignmentRight;
}
i set it to left and then center in same function upon rotation, that seems to fix it until they fix the bug! :)
This appears to be a bug in UIKit. Please file a bug report, including this sample project and images. It'd be nice if the sample app worked for both iPhone and iPad.
I agree that the text should stay flush with the right edge of the textfield.
精彩评论