3

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

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

在我的 rootviewcontroller 中,我使用 UIInterfaceOrientationMaskAll 实现了与下面的代码相同的代码,之后,我使用 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];

}

请帮我解决这个问题。

4

1 回答 1

3

您需要回答NOrootViewController 中的 shouldrotate 方法才能正常工作。

看看文档

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

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

于 2013-05-25T05:39:53.180 回答