于ios6后,ios系统改变了屏幕旋转的方法,假设您想将屏幕旋转法,在需求rootvc里面制备,例如
UIViewController *viewCtrl = [[UIViewController alloc] init];  
UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:viewCtrl];  
if ([window respondsToSelector:@selector(setRootViewController:)]) {  
    self.window.rootViewController = navCtrl;  
} else {  
    [self.window addSubview:navCtrl.view];  
} UITabBarController+autoRotate
@interface UITabBarController (autoRotate)
-(BOOL)shouldAutorotate;
- (NSUInteger)supportedInterfaceOrientations;
@end
#import "UITabBarController+autoRotate.h"
@implementation UITabBarController (autoRotate)
- (BOOL)shouldAutorotate {
    return [self.selectedViewController shouldAutorotate];
}
- (NSUInteger)supportedInterfaceOrientations {
    return [self.selectedViewController supportedInterfaceOrientations];
}
@end
@interface UINavigationController (autoRotate)
-(BOOL)shouldAutorotate;
- (NSUInteger)supportedInterfaceOrientations;
@end
@implementation UINavigationController (autoRotate)
- (BOOL)shouldAutorotate {
    return [self.visibleViewController shouldAutorotate];
}
- (NSUInteger)supportedInterfaceOrientations {
    return [self.visibleViewController supportedInterfaceOrientations];
}
@end
UIViewController1.m
- (BOOL)shouldAutorotate {
    return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
   return UIInterfaceOrientationMaskPortrait;;
}
UIViewController2.m
- (BOOL)shouldAutorotate {
   return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
   return UIInterfaceOrientationMaskAll;
}參考文章:IOS6屏幕旋转具体解释(自己主动旋转、手动旋转、兼容IOS6之前系统) , 在IOS应用中从竖屏模式强制转换为横屏模式 , http://stackoverflow.com/questions/12522903/uitabbarcontroller-rotation-issues-in-ios-6
版权声明:本文博主原创文章。博客,未经同意不得转载。
什么时候rootViewController至tabbarController时刻,控制屏幕旋转法
原文:http://www.cnblogs.com/mengfanrong/p/4887834.html