Reputation: 301
So I have an app with a view controller which changes view when rotated to landscape. In this view, the user can tap large images in a UIScrollView which will push a new view controller. However, the view controller which is pushed does NOT support landscape orientation.
This is a problem as when the user taps on the image in the first controller, the second one loads and automatically rotates the portrait-only view into landscape mode which looks ugly.
So the question is; how can I (probably in viewWillAppear) force the orientation to change to portrait even though the user is holding the device in a landscape position? I've tried [[UIApplication sharedApplication] setStatusBarOrientation:] as mentioned elsewhere but with no joy.
Upvotes: 0
Views: 905
Reputation: 11476
The pushed navigation controller which is to support portrait-only orientation should have this method implemented:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
Set it to return the supported orientation/s, so in this case it'd be:
return (interfaceOrientation == UIInterfaceOrientationPortrait); // and probably portrait upside-down, if it's on the iPad
Upvotes: 1