【发布时间】:2012-09-13 17:49:19
【问题描述】:
我在 iOS 中有一个通用项目,它在所有方向上都运行良好,但在 iOS 6.0 中
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
方法不再调用。
其他方法都行不通。
建议我一些快速的解决方案。
【问题讨论】:
标签: ios
我在 iOS 中有一个通用项目,它在所有方向上都运行良好,但在 iOS 6.0 中
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
方法不再调用。
其他方法都行不通。
建议我一些快速的解决方案。
【问题讨论】:
标签: ios
将此方法添加到您的视图控制器:
- (BOOL) shouldAutorotate {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
return YES;
} else {
return NO;
}
}
这为我解决了这个问题。但是,就 iOS 6 发行说明而言,我不应该这样做:
“为了兼容性,仍然实现 shouldAutorotateToInterfaceOrientation: 方法的视图控制器不会获得新的自动旋转行为。(换句话说,它们不会回退到使用应用程序、应用程序委托或 Info.plist 文件来确定支持的方向。)”。
【讨论】:
您必须改写 - (NSUInteger)supportedInterfaceOrientations 和 - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation。
阅读 Apple 文档,或观看 2012 WWDC 的会议。
【讨论】: