Howdy, Stranger!

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

Swapping Views (Chapter 5) - portrait view does maintain after changing to/from landscape.

I implemented the project exactly as stated -- two view (portrait and landscape)... and all code from book.  
When start the app in simulator:
1) portrait has two buttons stacked on top of each other.
2) switch to landscape orientation - new view displays correctly -- two buttons side by side.
3) switch back to portrait orientation - the two buttons still display side by side - not stacked on top of each other.

Any ideas why after switch away from portrait and then back again -- the buttons don't maintain their (stacked on top of each other) positions?


  • Check that you have this code in your willAnimateRotationToInterfaceOrientation:duration method:

        if (interfaceOrientation == UIInterfaceOrientationPortrait)


            self.view = self.portrait;

    and if you do, make sure that you have the outlet defining "portrait" attached to the property in your .h file correctly.

    I just finished going through Chapter 5, and the rotation to and from portrait works fine for me. 
  • I had a similar issue but with the buttons staying stacked like they are in portrait view. Turns out when I used code sense I had UIInterfaceOrientationMaskLandscapeLeft instead of UIInterfaceOrientationLandscapeLeft. Once I removed the Mask everything worked perfectly.
Sign In or Register to comment.