UITextField Position Instead of Correct Alignment and Reorientation

I'm not sure if I found an error or missed some complicated settings in the iOS SDK.

I have a UITextField with the right aligned text and some placeholder text. I configured it to automate when switching from portrait to landscape (IB settings look like this: http://db.tt/laTmXIS ).

When in the portrait everything works as expected: http://db.tt/skf8wqN However, after turning the text, the placeholder is in the wrong place: http://db.tt/7pU5kdR

It seems to me that the auto-implementation properties are not replicated to the subhead of the UILabel subclass.

I reproduced this in a new project (download here: http://db.tt/OSnvv2Y ), so nothing is scared in my code so far I see.

Any ideas?


Update: Dan workaround resolves this. Add an IBOutlet connected to your text field, and then add this code to your UIViewController ...

 - (void)didRotateFromInterfaceOrientation: (UIInterfaceOrientation)fromInterfaceOrientation { textField.textAlignment = UITextAlignmentLeft; textField.textAlignment = UITextAlignmentRight; } 
+8
ios objective-c iphone uitextfield
source share
2 answers

I set it to the left and then center in the same function on rotation, which seems to fix it until they fix the error! :)

+9
source share

This seems like a bug in UIKit. Please write a bug report , including this sample project and images. It would be nice if the sample application worked on both the iPhone and iPad.

I agree that the text should remain at the same level as the right edge of the text box.

+1
source share

All Articles