【问题标题】:UIDeviceOrientationDidChangeNotification returns wrong orientationUIDeviceOrientationDidChangeNotification 返回错误的方向
【发布时间】:2014-04-22 16:59:39
【问题描述】:

我有一个带有子视图的UIScrollView,我必须在方向更改时更新其框架。我一直在iPhone 模拟器上运行该程序,但看起来UIDeviceOrientationDidChangeNotification 没有返回设备的正确方向。当我旋转到UIInterfaceOrientationLandscapeLeft/Right 时,它返回UIInterfaceOrientationPortrait,反之亦然。是我使用不当还是必须使用其他方法来处理方向变化?

【问题讨论】:

  • 请注意,在 iOS 7 上,iPhone 不支持 UIInterfaceOrientationPortaitUpsideDown。这可能会在旋转模拟器时引起一些混乱,因为没有简单的方法来区分屏幕上的两种状态。

标签: ios objective-c ios7 uiscrollview uideviceorientation


【解决方案1】:

UIInterfaceOrientation != UIDeviceOrientation。 UIInterfaceOrientation 被声明为 ...

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

...纵向包含相同的值/数字,但交换了横向变体等。您没有显示您的代码,因此,我可以假设您将这两个东西混合在一起。

您有什么理由不使用willRotateTo...、willAnimateRotation...、didRotateFrom... 的UIViewController 方法吗?

【讨论】:

  • 谢谢。这帮助了我。我确实混淆了这两者。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多