Reputation: 4029
I am wandering if there is a way in which you could know what is going to be an UI element's frame after rotation. I need this in willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
in order to set other element relative to this one.
In this method , if you check the frame of an UI element , it will be the frame before the rotation since it's called WILLrotate...
I know I can do this in didRotate...
, but that would look bad . I want to set the new frames in an animation while the screen is rotating. I know I can just hardcode the values but that doesn't look like much of a solution.
Cheers,
George
Upvotes: 0
Views: 129
Reputation: 41642
Well, you can do it. If you know the "springs and struts" that you see in Interface Builder - well they are bits in a bitmask for the "autoresizingMask" property of your primary view. Since you know your view is going to change its frame, you can take any arbitrary view in the primary view's subviews (and those views subviews), and starting from the primary view, work your way down determining what each container's frame will be after the rotation.
For example, if you have a UITextField with frame 10,460,300,10, and it has a horizontal spring, and is anchored to the left, right, and bottom - then when the view rotates from a width of say 320 to 480, then the new frame will be 10,300,460,10.
Upvotes: 1