title: navigation controller pushViewController transitioning between landscape and portrait views doesn't work?
body: <p>I'm trying to get navigation between views that support landscape <em>or</em> portrait orientations  working using a navigation controller and pushViewController (and IOS6+ code) and have a problem where after pushing a landscape view controller onto the navigation controller stack, the view controller view correctly is in landscape but the device is still in portrait orientation. (imagine an arrow pointing left to right on a landscape screen, here it points from down to up on a portrait screen so the dimensions are correct - it's just the device should be in landscape mode so the arrow points left to right - if that makes sense)</p>
  
  <p>I have a portraitViewController and landscapeViewController that my different sub modes use.</p>
  
  <p>Using the iOS 6 method, The two classes overload</p>
  
  <pre><code>-(BOOL)shouldAutorotate;
  -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation;
  -(NSUInteger) supportedInterfaceOrientations;
  </code></pre>
  
  <p>appropriately.</p>
  
  <p>I also have my own derived navigationcontroller that overrrides:</p>
  
  <pre><code>-(BOOL)shouldAutorotate;
  -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation;
  -(NSUInteger) supportedInterfaceOrientations;
  </code></pre>
  
  <p>with the functions returning the same functions of the top view controller (so we're not bound to portrait mode by the top level view controller).</p>
  
  <p>My first problem is that the device doesn't do an orientation refresh when you use pushViewController onto the navigation controller. This is well documented and has been solved up to now by using dismissViewController and presentViewController which forces a device orientation refresh which in turn queries the new view controller about what orientations it supports and switches the device appropriately.</p>
  
  <p>This works but loses transitioning between view controllers (i.e with the new view sliding in from the right of the screen) as the previous view is removed from screen before the next is added and the newly presented view is applied to the entire screen directly.</p>
  
  <p>Because of this, I've been trying to get things working using pushViewController rather than present / dismissViewController. pushViewController works fine when I navigate from portrait to portrait view - the new view slides in nicely - it's when I switch from a portrait to landscape view controller than things break.</p>
  
  <p>Just pushViewController doesn't cause the device to refresh it's orientation and query what the new view would like to use. I've added calls to present / dismissModalViewController before my call to pushViewcontroller to force an orientation check with the new view controller. </p>
  
  <p><strong>* the problem *</strong></p>
  
  <p>This doesn't work however because the view is now in landscape mode but the device is still in portrait mode so the view is at 90 degs to what it should be.</p>
  
  <p>I've tried fixing this by setting the status bar orientation to match the view controller landscape orientation but this causes massive problems when the user manually rotates the device from then on as they aren't in sync. Also in iOS 6, you can't do that if your view controller returns YES from shouldAutoRotate function (calls to setStausBarOrientation are ignored if you control orientation yourself in your view controller) so it took a large hack to do it and it just doesn't feel like the right solution. </p>
  
  <p>To summarise, how can I use a navigation controller &amp; pushViewController (using iOS6) and switch between landscape and portrait views properly? At the moment, I can't get the device to update along with the view so the interface is in landscape but the device is still in portrait. If I try using setStatusBarOrientation to force the device to landscape, things start to go wrong as soon as I manually rotate the screen and it requires such a hack it just can't be the right answer.</p>
  
  <p>thanks!</p>
  
  <p>:-)</p>