【问题标题】:Why is shouldAutorotateToInterfaceOrientation not called in rotation 5,6?为什么轮换 5,6 时不调用 shouldAutorotateToInterfaceOrientation?
【发布时间】:2011-09-26 13:02:16
【问题描述】:

一切都很好,“shouldAutorotateToInterfaceOrientation”方法被调用用于标准方向,如纵向、纵向向下、横向和横向。但是,我注意到当 iphone 面朝下或面朝上躺在桌子上时,它不会被调用。在我的代码中 [UIDevice currentDevice].orientation 为此返回了一些值,例如 5 和 6,但是,正如我所说,这些方向不会调用旋转事件方法。我错过了什么吗?

【问题讨论】:

    标签: iphone objective-c rotation


    【解决方案1】:

    为什么会这样?如果用户将设备平放在桌子上,界面方向应该如何反应?设备无法判断哪个方向是“正确的”方向。

    设备方向≠界面方向

    【讨论】:

      【解决方案2】:

      interfaceOrientation 应用程序用户的方向 旋转后的界面。可能的值在 UIInterfaceOrientation。

      typedef enum {
         UIInterfaceOrientationPortrait           = UIDeviceOrientationPortrait,
         UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
         UIInterfaceOrientationLandscapeLeft      = UIDeviceOrientationLandscapeRight,
         UIInterfaceOrientationLandscapeRight     = UIDeviceOrientationLandscapeLeft
      } UIInterfaceOrientation;
      

      如您所见,方向是界面方向,而不是设备方向。

      您可能想看看:Reading the accelerometer

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-06-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-09-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多