Reputation: 1603
I need to calculate a UILabel's height when the device rotates, so I can adjust its frame in order to set the appropriate height needed to display its text.
I want the resetting of the frame to be as smooth as possible, which is why I tried to do the calculation and framesetting in the willRotateToInterfaceOrientation:duration: method. In this method, however, the bounds of the UILabel's superview are still valid for the old orientation.
When I do the same calls in the didRotateToInterfaceOrientation:duration: method the framesetting isn't very smooth and feels kinda sluggish (but at least I can do the proper calculations using the superviews bounds.width).
Now to my question: Is there a way to determine the width of a UIView at a given InterfaceOrientation so I can do the calculation described above? I want to do this as generic as possible since I will use the code on both the iPad and the iPhone.
If this is not possible, is there an elegant way to do what I've described above?
Thanks.
Upvotes: 3
Views: 357
Reputation: 47759
Subclass UIView for your main view and override layoutSubviews. The will/didRotate interfaces aren't real useful.
Upvotes: 2