问题
So, as by the question, I use the following code to set userinterfaceOrientation for the viewcontroller.
- (BOOL) shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
I tried setting UIInterfaceOrientationMaskAll
for another viewController.
Prior, I checked all the items for Supported interface orientations
in the info-plist. Both the viewControllers returned true
(as set in the info-plist) for all the orientations and didn't obey the above code. IT worked even in the absence of the above code. Is there anyway to restrict certain Supported interface orientations
for particular classes? I made it working for the pre - iOS6 versions by following this link.
回答1:
I was able to accomplish this by placing my supported orientation logic in a custom UINavigationController. I then segue to the relevant view controller.
@implementation PortraitNavigationController
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait;
}
...
回答2:
I'd say implement your shouldAutorotateToInterfaceOrientation:
on every view controller to make it return only YES
for those orientations you wish to support.
来源:https://stackoverflow.com/questions/12600867/set-different-supportedinterfaceorientations-for-different-uiviewcontrollers