iPhone按需轮换

时间:2011-01-05 11:48:16

标签: iphone ipad rotation orientation

有没有办法手动检查设备的当前位置并要求设备自动旋转它而无需等待用户实际旋转设备?

目前我在-shouldAutorotateToInterfaceOrientation中使用几个IF控制旋转,但在少数情况下我必须停止视图旋转并再次启用它,我不希望用户将设备旋转两次以获得所需的方向。

1 个答案:

答案 0 :(得分:0)

用于检查方向

UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];

然后根据您的情况,您可以根据需要更改设备方向..

你可以使用:

[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationPortrait;

或者你想要什么。

或者你可以去追踪,但这不是

[[UIDevice currentDevice] setOrientation:UIDeviceOrientationPortrait];