【问题标题】:shouldAutoRotate method not working properly..?shouldAutoRotate 方法不能正常工作..?
【发布时间】:2010-08-26 08:08:03
【问题描述】:

我在基于拆分视图的 ipad 应用程序中使用了多个 uiviewcontroller。 有网络服务。对于某些特定的 Web 服务(例如注销),我需要删除拆分 查看并插入新视图,即登录屏幕。但大多数时候,登录视图的 shouldAutoRotate 方法不会被调用,从而导致不旋转的愚蠢应用程序。 这背后的原因可能是什么?我该怎么办?

【问题讨论】:

    标签: iphone objective-c ipad


    【解决方案1】:

    为了维护我的旧代码,我添加了这个。

    - (BOOL)shouldAutorotate{
        UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
        if (orientation == UIDeviceOrientationUnknown) return YES;
        BOOL result = [self shouldAutorotateToInterfaceOrientation:orientation];
        return result;
    }
    

    那么原代码返回有效的自转信息。

    【讨论】:

      【解决方案2】:

      确保你没有从你的 UIViewController 中提取 UIView,它 shouldAutorotateToInterfaceOrientation: 函数返回 YES,然后使用 addSubView 将 UIView 添加到另一个 UIView。我以前也遇到过。

      【讨论】:

      • 实际上我通过下面的链接,我发现我在窗口中添加 2 个视图做错了。即登录视图和拆分视图。现在我已经将 loginview 呈现为模式视图,它解决了我的问题。现在我的应用程序可以很好地旋转。谢谢。
      【解决方案3】:

      确保您的所有视图控制器都为您的 iPad 版本返回 YESshouldAutorotateToInterfaceOrientation: —— 至少是当时可见的那些。

      见:iPad orientation change issue

      【讨论】:

      • 好的,谢谢它对我有帮助,我会试试的。实际上在 shouldAutorotateToInterfaceOrientation: 方法中我计算了视图控制器的大小,但给出了错误的大小,即它提供了前一个方向大小而不是当前。所以我根据尺寸做了一些手动调整。会不会有影响?
      猜你喜欢
      • 2014-10-22
      • 2016-08-01
      • 2012-11-08
      • 1970-01-01
      • 2015-06-29
      • 2021-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多