Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

Handling autorotation and subview centering

bolivaboliva Posts: 28Registered Users
Hi all,

I need some advice on the following. I have an app that runs full screen (without status bar). On the appDelegate, I instantiate a custom viewController and add its view as a subView to the window.

On my custom viewController, I have a view hierarchy created programatically (no IB). Its view property is created with the entire screen frame, and then I add to it a subView which is a rectangle shaped UIView, centered both horizontally and vertically. The result I get is this:

image

Which is correct. On my viewController, I have overriden the shouldAutorotateToInterfaceOrientation method to always return YES. The problem I have is that, after changing the orientation of the device from portrait to landscape, my subview isn't centered, as the rotation happens considering its origin relative to the superview and keeping the same position after rotation:

image

As you can see, the black rectangle isn't centered after the screen rotation takes place. I can however recenter it by implementing willRotateToInterfaceOrientation:duration: on my viewController; however the recentering is 'jumpy' because I set the new position before the rotating animation starts. This is true also if I try to do it on didRotateFromInterfaceOrientation:.

So basically what I want is that my black rectangle subView rotate over its own center when the screen orientation changes, instead of keeping its position relative to its container superview.

Hope you can help me out.

Best regards,
Post edited by boliva on

Replies

Sign In or Register to comment.