1
votes

I am trying to push a portrait only view controller onto a controller that allows portrait or landscape. The issue I'm having is that if the user is in landscape mode and I push the new controller on it will remain in landscape mode and just look all screwed up. How do I force the orientation to change to portrait as the new view controller is pushed on?

2

2 Answers

2
votes

KDaker's answer is correct but another option you can think about is whether you can limit navigation when your orientation isn't what you want. This isn't necessarily a good idea but there are situations where it can work well. An example would be if you had a video which when rotated to landscape became full screen and covered your navigation back button until it returns to portrait.

1
votes

in iOS 5 and anything before you cant 'force' an orientation from one view to another. You can support only one orientation for the project but then allow autorotation. So in your case, you can only allow autorotation and wait for the user to rotate the device.

In iOS 6, they have changed the way orientation handling works, and its become alot more flexible. You now have these methods:

- (NSUInteger)supportedInterfaceOrientations

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation

Using these, you can present your view controller in any orientation you prefer, given that it is supported in the former method.

hope this helps.