【问题标题】:iOS 6.0 -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation not callingiOS 6.0 -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 不调用
【发布时间】:2012-09-13 17:49:19
【问题描述】:

我在 iOS 中有一个通用项目,它在所有方向上都运行良好,但在 iOS 6.0 中

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation

方法不再调用。

其他方法都行不通。

建议我一些快速的解决方案。

【问题讨论】:

    标签: ios


    【解决方案1】:

    将此方法添加到您的视图控制器:

    - (BOOL) shouldAutorotate {
        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
            return YES;
        } else {
            return NO;
        }
    }
    

    这为我解决了这个问题。但是,就 iOS 6 发行说明而言,我不应该这样做:

    “为了兼容性,仍然实现 shouldAutorotateToInterfaceOrientation: 方法的视图控制器不会获得新的自动旋转行为。(换句话说,它们不会回退到使用应用程序、应用程序委托或 Info.plist 文件来确定支持的方向。)”。

    iOS 6 Release Notes

    【讨论】:

      【解决方案2】:

      您必须改写 - (NSUInteger)supportedInterfaceOrientations- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation。 阅读 Apple 文档,或观看 2012 WWDC 的会议。

      【讨论】:

      • 我想设置对象的框架,但没有一个方法在定向时调用
      • 实际上,iOS 6 发行说明中写道:“为了兼容性,仍然实现 shouldAutorotateToInterfaceOrientation: 方法的视图控制器不会获得新的自动旋转行为。(换句话说,它们不会回退到使用应用程序、应用程序委托或 Info.plist 文件来确定支持的方向。)”。我也遇到了向后兼容性问题。
      猜你喜欢
      • 2011-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多