ios - 在 iOS 7 中强制横屏和自动旋转

标签 ios ipad ios-simulator ios7

我的应用应该是横向的,在为 iOS 6 和更早版本构建时我没有遇到这个问题。现在使用 iOS 7,它根本不会旋转。

在我的应用程序设置中,我将其设置为仅向左/向右横向。在我的 View Controller 中,我使用以下内容:

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight;
}

我以前也用过这个,现在已经弃用了:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation {
    return UIInterfaceOrientationIsLandscape(orientation);
}

新的似乎是 shouldAutorotate,但使用它会使我的应用程序崩溃。对此有任何想法将不胜感激,因为我的应用程序被迫在我的 iPad 和模拟器中纵向显示。谢谢!

最佳答案

这解决了我的问题。我不确定我之前为什么会遇到问题,但我一定是错过了尝试这个确切的组合(另外,info.plist 应该设置了支持的方向)。

(NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

(BOOL)shouldAutorotate {
    return YES;
}

编辑:我可能在使用模拟器时遇到问题,进行重置/重新启动和清理可能有助于修复。

关于ios - 在 iOS 7 中强制横屏和自动旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18959740/

相关文章:

iphone - 方法声明错误 textfielddidbeginediting

iphone - 向 NSMutableURLRequest 添加字段

iphone - 访问模拟器的 NSLibraryDirectory 时出现 NSFileNoSuchFileError

swift - 在系统符号集中找不到名为 'xxx' 的符号

ios - UIImageView 适合自适应表格 View 单元格中的最大宽度

ios - Swift 显示来自 viewController 的 jpg 图片

ios - 页面 curl 模式 segue : leave bottom bar on screen

iphone - (viewConroller.view removeFromSuperview) 线程 :1 EXC_BAD_ACCESS (Code=1, 地址 = 0x6000000008)

ios - 在不同的 Mac/模拟器上运行 iOS 应用程序

ios - UITableView 分隔符样式缺失的行