ios - UIDeviceOrientationDidChangeNotification 返回错误的方向

标签 ios objective-c ios7 uiscrollview uideviceorientation

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

最佳答案

UIInterfaceOrientation != UIDeviceOrientationUIInterfaceOrientation 声明为 ...

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/

相关文章:

objective-c - 如何将数据保存到用户的应用程序支持中?

ios - 为什么当我认为我没有改变任何东西时,我突然在 Xcode 中收到随机错误?

ios - 编译适用于 iOS 6 和 iOS 7 的应用程序

ios - 为什么字符串格式在 UILabel 中不起作用?

ios - 适用于iPhone/iOS的PhoneGap/Cordova Barcodescanner插件

ios - 如何从垃圾图标按钮和 'Done' 按钮动态切换 UIBarButtonItem?

ios - 使用 NSURLConnection 运行 NSOperation 的多个实例?

objective-c - 尝试通过 viewWithTag 获取 UIImageView 引用后崩溃

iphone - 没有为 UITableView 调用 numberOfRowsInSection

javascript - 对话框在 iOS 7 全屏 Web 应用程序中不起作用