title: iPhone (iOS 5) forcing portrait from landscape and going back
body: <p>I'm working on application for iOS 5 and I have one controller which needs to be pushed in portrait view. It's quite tricky to push controller in portrait mode from the landscape but finally I figured out how to do that. I show controller by <code>presentModalViewController</code> or by <code>pushViewController</code> and inside the controller I override <code>preferredInterfaceOrientationForPresentation</code> metod.</p>
  
  <pre><code>-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
  {
      return UIInterfaceOrientationPortrait;
  }
  </code></pre>
  
  <p>It works fine just it has one problem. Below is the scenario.</p>
  
  <ol>
  <li>User holds the device in landscape mode and current controller is correctly shown in landscape mode</li>
  <li>User make some action and the portrait only controller appears (as modal controller and in portrait mode)</li>
  <li>User close the modal controller</li>
  <li>Previous controller which works in landscape is now in portrait, but user still holds his device in landscape ---> This is the problem</li>
  </ol>
  
  <p>I tried to fix it by calling <code>[UIViewController attemptRotationToDeviceOrientation]</code> but it doesn't help.</p>
  
  <p>Thanks for any help in advance.</p>