I’ve spent the last week adding changes to the Prescriber’s Letter app.  One of the changes was to add support for browsing all the content in landscape mode.  Supporting landscape and portrait orientations quickly exposes any shortcuts you’ve taken in the design and implementation of your views.  Not to say that I took lots of shortcuts, actually most of my stuff just worked, but there were a few points where I could have saved myself sometime if I’d planned for landscape support from the beginning.  One of those was how I initially chose to do the login screen.  I knew when I was doing it that I should create the login screen as its own view controller and then present it modally.  It was more efficient at the time though to just add the login screen as another view to the root view controller and slide it in and out myself (since the whole screen is generated by code).  Once it came to adding landscape support we didn’t want to have the login screen rotate to landscape.  Now I was in trouble.  There’s no way to “force” a UIViewController to rotate to one direction or another.  You can screw around with writing your own code to perform matrix transformations on your view, but in my opinion that’s just a hack waiting to bite you in the ass.  Really you need to redesign your system so that the view is reloaded, and currently in the latest SDK  reloading (or loading) the view guarantees that the return value of shouldAutorotateToInterfaceOrientation: is respected.  So I converted everything for the login screen over to its own view controller that returns NO to any orientation but portrait, and then present it modally.  No matter what orientation the root view controller is in this brings up the login screen in portrait mode.

I’m off to Mexico now for a well deserved vacation with my wife (who deserves it more than me), away until February 26th!  Lucky me.

Share:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Slashdot
  • TwitThis
 

Leave a Reply