开发者

Determining the size of a UIView at a given orientation

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 slu开发者_如何学Cggish (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.


Subclass UIView for your main view and override layoutSubviews. The will/didRotate interfaces aren't real useful.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜