Reputation: 1113
I am making a navigation based app and I need only portrait orientation except in a ZoomPictureViewController
( Zoom in, zoom out images) that supports all orientations.
I am presenting ZoomPictureViewController
and returning YE
S in shouldAutorotateToInterfaceOrientation:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}
But I get no rotation. I know that shouldAutorotateToInterfaceOrientation
, willRotateToInterfaceOrientation
, RotateToInterfaceOrientation
are only get called on the current/visible view controller but this is not happening in my case. I have checked it via putting breakpoints and NSLog
.
Upvotes: 0
Views: 231
Reputation: 73688
Are you using any type of Navigation Controller or a Tab View Controller? I've noticed that there are issues when rotating a UIView that's not the first or only view as a direct child of the main window.
So if your UIView is part of a Navigation Controller or a Tab View Controller, you'll also need to override shouldAutoRotateToInterfaceOrientation
on the Navigation Controller or Tab View Controller.
Also I here's an important gotcha in the Apple documentation that might explain the problem you are having.
Tab bar controllers support a portrait orientation by default and do not rotate to a landscape orientation unless all of the root view controllers support such an orientation. When a device orientation change occurs, the tab bar controller queries its array of view controllers. If any one of them does not support the orientation, the tab bar controller does not change its orientation.
Upvotes: 1