如何旋转到Orientation的当前?

时间:2010-03-12 05:53:46

标签: iphone

根据我的代码,我的设备在Landscape中使用

当我pushViewController它将

在UIDeviceOrientationPortrait中自动显示。

我需要将设备旋转到纵向,然后旋转到横向,

然后它将以横向模式显示。

如何在不使用私有API(setOrientation)的情况下旋转到Orientation的当前状态?

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIDeviceOrientationPortrait) ||
            (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}

1 个答案:

答案 0 :(得分:2)

尝试设置状态栏方向:

UIApplication *app = [UIApplication sharedApplication];
[app setStatusBarOrientation: UIInterfaceOrientationLandscape];
[app setStatusBarHidden: NO animated: YES];

您可以像这样获取当前的设备方向:

[UIDevice currentDevice].orientation
相关问题