Howdy, Stranger!

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

Chapter 5: Moving the Views on Rotation Exercise


I'm fairly new to iOS programming (completed the "Programming in Objective-C" by Stephen Kochan, and now I'm moving on to "Beginning iOS 7").  

I completed the "Moving the Views on Rotation" exercise from Chapter 5 but when I actually launch the finished product in the simulator, I see some not so pretty results.  

When I launch initially in portrait view, the content is exactly the way it should be.  However if I rotate the view into landscape, or if I rotate the view back to portrait, the content does not align with what is expected and is all over the place.  Also, the notification bar along the top is not stretched across the entire screen and the background becomes black in a large portion of the main view.

I'm attaching three images to demonstrate what I'm seeing and I wanted to find out if anyone else is observing this as well.  I can say that I've checked all my code against the book and I'm fairly confident that it is all correct as described.

I don't mind trying to find out how to fix the issue myself since I know that is the best way to learn, but I wanted to make sure in case the content in the book is not quite right for this particular exercise.

Portrait - First Launch:

Landscape - Rotate Left:

Portrait - Rotate back to portrait:

Thanks in advance and I love the book!


  • So, that second image looks really weird. Definitely not what I had in mind, nor what I saw when writing that chapter. Maybe you should download the source archive, verify that it works there, then see if you can spot the difference.

    The final difference looks the same as the second one, just rotated. Are you sure you had rotated the simulator back to normal portrait, or did you maybe take it the other direction to upside-down portrait? By default, iPhone apps are configured in Xcode to NOT rotate into upside-down orientation, so they'll typically end up sideways in the simulator.
  • Hi Jack,

    I should've followed your suggestion before I posted, by cross referencing my source with yours.   

    After comparing your storyboard to my version, I know what I did wrong now: I interpreted the text in the book literarily (from page 136): "Now do the same for the large view, naming this outlet contentView.".

    By "large view" I thought this meant the parent view, instead of the view with the colored square.  Once I recreated the contentView outlet by properly associating it to the correct view, everything is working flawlessly;

    Thanks for the help.  I learned an important lesson with this one. :)
  • Glad I could help!

Sign In or Register to comment.