Re: rotating UIView without changing size
Re: rotating UIView without changing size
- Subject: Re: rotating UIView without changing size
- From: David Duncan <email@hidden>
- Date: Fri, 03 Aug 2012 08:50:29 -0700
On Aug 3, 2012, at 8:34 AM, Gerriet M. Denkmann <email@hidden> wrote:
> I have a subclass of UIViewController which displays a small view in the center of the display.
> shouldAutorotateToInterfaceOrientation: returns YES.
>
> The problem:
> when I rotate the device, the centered view rotates as it should. But it also changes its size to full-screen.
>
> The (bad) workaround:
> in didRotateFromInterfaceOrientation: I set the frame back to a sensible value.
>
> Result: when I rotate the device, the view rotates, blows up to fill the screen, then snaps back to its real size.
>
> Is there a way to tell the ViewController to NOT mess with the size of its view (it should just exchange width and height)?
I'm confused between your two claims.
Above you say you have a view controller that displays a small view in the center of the screen. Below you say that this is the view controller's view (that is, the view assigned to the 'view' property). If both of these are true, then you've violated some expectation of UIKit. From the sounds of it, it is the one that expects that a view controller's consumes the entire screen (at least in the absence of view controller containment).
If you want a simple view in the center of the screen with a fixed size, then the simplest way to do so is to make that view a subview of the view controller's view. If you set the autoresizingMask correctly, then that view won't be resized at all, and should maintain its position in its superview (if nothing else ensuring the subview remains at the correct size and position should be much easier than what it seems you are trying to do above).
--
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