设置状态栏方向在iPad 2中的iOS 6中不起作用

时间:2013-05-25 05:27:05

标签: iphone ios objective-c ipad orientation

我找到了许多与我的问题相关的答案,但没人能帮助我解决我的问题。

正如我的标题所说,状态栏方向在iOS 6中没有变化。我为更改状态栏方向编写了正确的代码,但它对我不起作用。它不适用于iOS模拟器和放大器设备(iPad)。

在我的rootviewcontroller中,我使用UIInterfaceOrientationMaskAll实现了与bellow代码相同的功能,之后,我使用presentModelViewController来启用子视图控制器,但在子视图控制器中我无法更改状态栏方向。

我也实施了

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationMaskAll;
}
在AppDelegate中

我的代码是:

-(BOOL) shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}


-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
   [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];

}

请帮我解决这个问题。

1 个答案:

答案 0 :(得分:3)

你需要回答NO rootViewController中的shouldrotate方法才能正常工作。

查看文档

  

讨论此属性的值是一个表示a的常量   接收者状态栏的方向。请参见UIInterfaceOrientation   详情。设置此属性会将状态栏旋转到   指定方向而不设置过渡动画。如果你的   应用程序具有可旋转的窗口内容,但是,您不应该   使用此方法任意设置状态栏方向。的的   如果是,则此方法设置的状态栏方向不会更改   设备更改方向。有关可旋转窗口视图的更多信息,请参阅   适用于iOS的View Controller编程指南。

http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/occ/instp/UIApplication/statusBarOrientation