原文地址: http://blog.csdn.net/ginhoor/article/details/20454229
通过
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:YES];
方法的枚举可以设置状态栏方向,但是需要在viewController中重写
(BOOL)shouldAutorotate
{
return NO;
}
返回值为NO
如果此viewController在某个UINavigationController中需要在AppDelegate中写个类目
@implementation UINavigationController (Rotation)(BOOL)shouldAutorotate
{
//在viewControllers中返回需要改变的viewController
return [[self.viewControllers firstObject] shouldAutorotate];
}
@end
如果此UINavigationController在某个UITabBarController中需要在AppDelegate中再写个类目
@implementation UITabBarController (Rotation)
- (BOOL)shouldAutorotate
{
//在viewControllers中返回需要改变的NavigationController
return [[self.viewControllers firstObject] shouldAutorotate];
}
@end