iphone - iOS 5.1 应用程序与目标 iOS 5.1 一起运行 xcode 4.6.2,无法限制某些方向的 View ?

标签 iphone ios objective-c xcode4

我使用 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,因此您必须进行操作系统检查并实现/覆盖 supportedInterfaceOrientationspreferredInterfaceOrientationForPresentation 方法代替。

关于iphone - iOS 5.1 应用程序与目标 iOS 5.1 一起运行 xcode 4.6.2,无法限制某些方向的 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17210190/

相关文章:

iphone - CALayerInvalidGeometry',原因: 'CALayer bounds contains NaN: [0 0; nan nan] crash in view

iphone - 二进制剥离简而言之

objective-c - 寻找类似 objective c NSList 的选项,(我知道之前有人在这里问过),你能提供什么例子?

ios - 按完成或uitextfield的返回键调用函数

iphone - UISegmentedControl的选定段

ios - 如何在 AR 应用中同时包含和运行图像跟踪配置和世界跟踪配置

iphone - iPhone 中基于选项卡栏的应用程序和选项卡栏 View Controller 之间的区别?

ios - iOS8自定义键盘设置。 bundle 未显示

ios - 如何在使用 ios7 和 parse.com 的消息传递应用程序中将对话或消息标记为未读?

ios - 购买后更换背景图片