【问题标题】:Top-home button portrait orientation in iOS6 simulator not workingiOS6模拟器中的顶部主页按钮纵向方向不起作用
【发布时间】:2012-09-19 22:13:34
【问题描述】:

几分钟前我设置了 XCode 4.5 和 iOS6 模拟器。 我的应用支持 iPhone 的所有 4 方向, 纵向底部和顶部主页按钮,横向左右。

好吧,我把它放到 .plist 中,因为它是 iOS6 所要求的,而且旧的 shouldRotateTo... 方法仍然返回 YES。

但在模拟器中,应用旋转到纵向顶部主页按钮。

为什么?这是故意的吗?它可以在设备上正常工作吗?

谢谢。

【问题讨论】:

    标签: ios6 xcode4.5


    【解决方案1】:

    好的, 我现在自己找到了答案。

    拥有是不够的

    - (BOOL)shouldAutorotate {
    
        return YES;
    }
    
    - (NSUInteger)supportedInterfaceOrientations {
    
        return UIInterfaceOrientationMaskAll;
    }
    

    如果它被推入UINavigationViewController,则在您的 ViewController 中。 UINavigationViewController 也必须有这些方法。 最好通过在UINavigationViewController 上设置一个小类别来做到这一点。

    这是我的UINavigationController-Rotation.h

    @interface UINavigationController (Rotation)
    @end
    

    还有我的 UINavigationController-Rotation.m:

    #import "UINavigationController-Rotation.h"
    
    @implementation UINavigationController (Rotation)
    
    #pragma From UINavigationController
    
    - (BOOL)shouldAutorotate {
    
        BOOL result = self.topViewController.shouldAutorotate;
    
        return result;
    }
    
    - (NSUInteger)supportedInterfaceOrientations {
    
        NSUInteger result = self.topViewController.supportedInterfaceOrientations;
    
        return result;
    }
    
    #pragma -
    
    @end
    

    谢谢你帮助我!

    【讨论】:

      【解决方案2】:

      iOS6 在 iPhone 上的默认行为是没有颠倒方向。

      from UIViewController Class Reference: The default values for a view controller’s supported interface orientations is set to UIInterfaceOrientationMaskAll for the iPad idiom and UIInterfaceOrientationMaskAllButUpsideDown for the iPhone idiom.

      您也可以在 Safari 或地图中看到此行为。

      我试图用 UIInterfaceOrientationMaskAll 覆盖它,就像 Dean 说的那样,但没有效果。 我决定不再使用颠倒模式,因为它是一种我喜欢遵循的用户界面指南,而不是混淆用户。

      【讨论】:

      • 我并不着急,因为 iPhone 3GS-4S 上的麦克风放置,我真的想要倒置支持。
      【解决方案3】:

      我认为您的 viewControllers 将返回几乎颠倒的默认值。你需要实现:

      -(NSUInteger)supportedInterfaceOrientations
      {
          return UIInterfaceOrientationMaskAll;
      }
      

      对于您想要支持所有方向的所有视图控制器。

      【讨论】:

      • 不起作用。还确实在 plist 中设置了所有界面方向,从 ViewController 的 - (BOOL)shouldAutorotate 和 ...MaskAll 从 AppDelegate 的 - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window 返回 YES。
      • 在 iPad 模拟器上按预期工作。可能是 iPhone 版本中的错误?
      • 我将不得不更多地阅读新文档。我目前的期望是在 .plist 文件中设置它并在视图控制器中返回 maskAll 应该这样做。我记得提到过从 appDelegate 返回。那可能是缺少的部分。
      • 对我来说它有四个部分:1) 在我的 ViewController -(NSUInteger)supportedInterfaceOrientations,2) 正确的 plist 条目,3) - (BOOL)shouldAutorotate 在我的 ViewController 和最后丢失的位 4) UINavigationController 类别(看我自己的回复)。我已经有 1)-3) 并且它确实在 iPad sim 上正常工作,4) 最终让它在 iPhone 上运行。
      【解决方案4】:

      如果其他人在遵循 Christoh 的回答后仍有问题:

      我刚刚注意到项目 plist 对 iPad 和 iPhone 有单独的条目(支持的界面方向 (iPad) 和支持的界面方向 (iPhone))。

      希望对您有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-10-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-04-25
        • 2017-12-12
        相关资源
        最近更新 更多