我有一个带有 subview 的 UIScrollView
,我必须根据方向变化更新其框架。我一直在 iPhone
模拟器上运行程序,但看起来 UIDeviceOrientationDidChangeNotification
没有返回正确的设备方向。当我旋转到 UIInterfaceOrientationLandscapeLeft/Right
时,它返回 UIInterfaceOrientationPortrait
,反之亦然。我是不是没有正确使用它,还是必须使用其他一些方法来处理方向变化?
最佳答案
UIInterfaceOrientation
!= UIDeviceOrientation
。 UIInterfaceOrientation
声明为 ...
typedef enum : NSInteger {
UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait,
UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,
UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft
} UIInterfaceOrientation;
...纵向包含相同的值/数字,但横向变体被交换等。您没有显示您的代码,所以,我可以假设,您将这两个东西混合在一起。
有什么理由不使用 willRotateTo...
、willAnimateRotation...
、didRotateFrom...
方法UIViewController
?
关于ios - UIDeviceOrientationDidChangeNotification 返回错误的方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22455210/