5

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!

1
  • I still have the same question after many years :-) Trying to use stackview with size classes but animation while rotating looks awful. Jul 23, 2018 at 18:17

1 Answer 1

2

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.

3
  • 1
    I tried that but the animations didn't look quite smooth/right. May 6, 2010 at 17:37
  • 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 :] May 10, 2010 at 14:38
  • Ah, that makes sense. Good luck with your app!
    – Pyro2927
    May 12, 2010 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.