【问题标题】:Set Statusbar Orientation is not working in iOS 6 in iPad2设置状态栏方向在 iPad2 的 iOS 6 中不起作用
【发布时间】:2013-05-25 05:27:04
【问题描述】:

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

正如我的标题所说,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];

}

请帮我解决这个问题。

【问题讨论】:

  • 您在应用程序委托中将状态栏方向设置为纵向,在根视图中将视图设置为全部屏蔽。如果您在根视图中使用他的方法,则无需在应用程序委托中应用该方法。您是否尝试过在应用程序委托中注释掉方向方法,并查看状态栏是否使用仅在根视图中应用的方法改变方向?

标签: iphone ios objective-c ipad orientation


【解决方案1】:

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

查看文档

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

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

【讨论】:

  • 嘿伙计...真的非常感谢您...:) 我通过您的代码解决了我的问题。
猜你喜欢
  • 2012-09-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-12-09
相关资源
最近更新 更多