Re: UIView Center does not seem to change with orientation change
Re: UIView Center does not seem to change with orientation change
- Subject: Re: UIView Center does not seem to change with orientation change
- From: David Duncan <email@hidden>
- Date: Mon, 16 Sep 2013 07:38:12 -0700
On Sep 13, 2013, at 1:27 PM, Rich Collyer <email@hidden> wrote:
> I am looking at at view that covers the entire iPhone screen. The app is also required to only work in Landscape. I see that in viewWillAppear the bounds and center of the view are in Portrait mode - this is fine. However, in viewDidAppear the bounds of the view are in Landscape, but the center is unchanged. This makes the center of the view incorrect, which make transformations wrong and any calculations based on the center of the view wrong.
>
> Should the app force a new center on an orientation change?
The center property of a view is in its superview’s coordinate system. What you describe sounds like the view is the view that is vended by the window’s root view controller, which has the unique property that to enable rotation it is transformed rather than resized. This can lead to some unexpected geometry if you are looking at the “wrong” thing.
Basically what it comes down to is that a view (or the view controller which returns it as a its view) should not be looking at the geometry it has that is expressed in the parent coordinate system (frame, center, transform) and should not modify its own bounds, as these values are effectively “owned” by the view’s superview. In your case, the odd frame origin is likely due to your alternation of the view’s bounds, as setting bounds alters the frame (since frame is derived from center, bounds, and transform).
--
David Duncan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden