0

我的应用程序应该以横向模式开始。我想改变手机的方向。如何手动执行此操作。我尝试过它不起作用。

 shouldAutorotateToInterfaceOrientation:

有没有别的办法??

4

1 回答 1

0

在项目设置中,您可以设置应用允许的方向。将其设置为 LandscapeLeft 和 LandscapeRight。这将阻止您的应用程序进入 Potrait 模式,无论您的应用程序启动之前设备的方向如何。

手动强制改变方向

在 iOS 中,您不能直接手动设置设备方向。但是,您可以使用此方法完成工作。

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft  animated:NO];

通常的方式

或者,您可以转到您的实现文件,您可以在此方法中指定允许的方向:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
//Return YES if you want to allow all orientations
return UIInterfaceOrientationLandscapeRight; //if you want to allow landscape right &c
}
于 2013-07-25T12:09:17.097 回答