views:

18

answers:

1

I am working on a universal iPhone/iPad app. I resize some of my UITextFields as the user types. I also have some code to move the UITextFields around so that their locations make sense as they are resized. This code is not too short, but basically it comes down to modifying the frames of the UITextFields.

My UITextFields all have their content vertically centered by setting

textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;

The text centers just fine. But when I resize the textfield on the iPad, the cursor sometimes goes to the top of the box. This looks strange to the user as the text is in the center.

This always happens on the iPad, never on the iPhone. Making matters worse, I can't isolate which particular part of the code causes it to happen -- except that if I stop resizing things, the problem goes away.

Has anyone else ever encountered this? Were you able to isolate the source of the problem?

Thanks.

A: 

I figured out what triggers the bug. It happens when textField is resized both by layoutSubviews and by a method triggered by UIControlEventEditingChanged.

William Jockusch