我使用 Xcode 4.4 和 iOS 5.1 开发了一个应用程序。我将 Xcode 更新为 4.6.2,iOS 为 6.1,但我选择目标为 iOS 5.1(即使我使用的是 Xcode 4.6.2)。我的应用程序支持所有方向。
我的问题是:我想限制横向模式下的某些 View ,它在模拟器中工作正常,但是当我在 iPhone 5 设备中运行该应用程序时,我的方法不起作用,请帮助我吗?
最佳答案
在您想要限制方向的 View Controller 中,我将执行以下操作:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return interfaceOrientation == UIInterfaceOrientationLandscape;
}
对于您的 iPhone 5,iOS6 已弃用 shouldAutorotateToInterfaceOrientation
,因此您必须进行操作系统检查并实现/覆盖 supportedInterfaceOrientations
和 preferredInterfaceOrientationForPresentation
方法代替。
关于iphone - iOS 5.1 应用程序与目标 iOS 5.1 一起运行 xcode 4.6.2,无法限制某些方向的 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17210190/