横向设备,但[[UIDevice currentDevice] orientation]报告纵向

时间:2013-02-25 16:35:34

标签: ios6

我的项目设置指示横向左和右是支持的界面方向。 当我的应用程序启动时,模拟器处于横向状态。

但是,此NSLog语句(在我的App Delegate或我的Root View Controller中)无法运行。

if (UIInterfaceOrientationIsLandscape([[UIDevice currentDevice] orientation])) {
    NSLog(@"I'm in landscape");
}

知道为什么吗?

我正在使用iOS6.1。

1 个答案:

答案 0 :(得分:0)

您可以使用代理

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
  return UIInterfaceOrientationLandscapeLeft;
}

使用此委托,应用程序将以横向模式或任何所需的方向模式显示。

试试吧。

相关问题