我的应用应该是横向的,在为 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/