繁体   English   中英

如何旋转到当前的方向?

[英]how to rotate to current of Orientation?

当我的设备在横向模式下使用时,根据我的代码

当我pushViewController它将

自动显示在UIDeviceOrientationPortrait中。

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

那么它将以横向模式显示。

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

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

尝试设置状态栏方向:

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

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

[UIDevice currentDevice].orientation

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM