无法在IOS6中设置StatusBarorientaion

无法在IOS6中设置StatusBarorientaion,ios6,Ios6,使用UINavigationController时,方向状态不会更改。 这是我的代码: AppDelegate.h文件 #import <UIKit/UIKit.h> @class MainViewController; @interface AppDelegate : UIResponder<UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @property (strong,

使用UINavigationController时,方向状态不会更改。 这是我的代码:

AppDelegate.h文件

#import <UIKit/UIKit.h>
@class MainViewController;
@interface AppDelegate : UIResponder<UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) MainViewController *mainViewController;
@end
MainViewController.m

...
-(NSUInteger)supportedInterfaceOrientations{
    return  UIInterfaceOrientationMaskLandscapeLeft;
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
    return UIInterfaceOrientationMaskLandscapeLeft;
}
-(BOOL)shouldAutorotate{
    return YES;
}
-(void) viewDidAppear:(BOOL)animated {

    [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeLeft;
    [self.navigationController setNavigationBarHidden:YES];
}
...

从iOS 6.0 SDK发行说明:

SetStatusBaroOrientation:animated:方法并没有完全被弃用。现在,仅当最顶端的全屏视图控制器的supportedInterfaceOrientations方法返回0时,它才起作用。这使得调用者负责确保状态栏方向一致

...
-(NSUInteger)supportedInterfaceOrientations{
    return  UIInterfaceOrientationMaskLandscapeLeft;
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
    return UIInterfaceOrientationMaskLandscapeLeft;
}
-(BOOL)shouldAutorotate{
    return YES;
}
-(void) viewDidAppear:(BOOL)animated {

    [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeLeft;
    [self.navigationController setNavigationBarHidden:YES];
}
...