tags:

views:

25

answers:

1

I'm trying to make an app that handles orientation/rotation similarly to the way the built-in Calc app does.

If you check out that app, in portrait mode there's a normal calculator, and if you rotate to landscape mode there are additional buttons that appear to the left.

I can't figure out how to do this by setting the autosize masks. The problem is the "normal" calculator view is 320px wide in portrait mode, but actually shrinks to around 240px in landscape mode to fit the additional controls.

I've seen examples like the AlternateViews sample app that have two different view controllers (one for portrait and one for landscape), but they don't seem to animate the transitions between the views nicely like the Calc app does.

I've also tried setting the frames for the views manually in willAnimateSecondHalfOfRotationFromInterfaceOrientation, but it doesn't seem to look "quite right" and also I'm not certain how that works with the autoresize mask.

Any ideas how this is done? Thanks!

A: 

Just override the following method call:

- (void)willRotateToInterfaceOrientation: (UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

Inside of there resize all of your components so they look nice.

Pyro2927
I tried that but the animations didn't look quite smooth/right.
Ray Wenderlich
Problem was that I still had the autosizing mask on, so that was messing with the animation results. When I turned it off things look acceptable (but still not as good as the calc app). Accepting this for now :]
Ray Wenderlich
Ah, that makes sense. Good luck with your app!
Pyro2927