转自:http://www.cocoachina.com/bbs/read.php?tid=183741
方法1:在要禁止的视图中,加入了下面的代码,无效。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return (toInterfaceOrientation == UIInterfaceOrientationPortrait);
}
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;//只支持这一个方向(正常的方向)
}
方法2:
http://stackoverflow.com/questions/17370806/disable-autorotate-on-a-single-uiviewcontroller-in-ios6/17377221#17377221
#import "UINavigationController.h"
#import "MonthCalendarVC.h"
@implementation UINavigationController (overrides)
- (BOOL)shouldAutorotate
{
id currentViewController = self.topViewController;
if ([currentViewController isKindOfClass:[MonthCalendarVC class]])
return NO;
return YES;
}
@end