ios - willRotateToInterfaceOrientation 和 deviceOrientationDidChange 之间有什么区别?

标签 ios orientation

在检测方向变化并对其使用react时,我看到了两种方法:实现 willRotateToInterfaceOrientation 或要求 View 开始发出相关通知 (deviceOrientationDidChange) .

什么时候打算使用后者?有什么好处?

最佳答案

willRotateToInterfaceOrientation:duration: 方法是 UIViewController 的一部分。如果您是从 UIViewController 派生的,则只需重写此方法即可获知方向更改。

但是,如果您在其他类(class)并希望了解方向变化,那么您需要注册 UIDeviceOrientationDidChangeNotification .

关于ios - willRotateToInterfaceOrientation 和 deviceOrientationDidChange 之间有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6758115/

相关文章:

iphone - 一个 View Controller ios 的强制景观

ios - MPMoviePlayerViewController 方向与设备不同

ios - 如何在 Beta 3 中设备旋转时正确处理自定义键盘

android - 如何在方向更改时保留 EditText 数据?

objective-c - 在 iOS 中使用 RestKit 解析 unix 时间戳

ios - 如何减少 iOS 应用程序的 Core ML 模型?

iOS PWA "Add to Home Screen"- 禁用全屏模式

ios - ReactiveCocoa : Correct use of signals for checking entity availability

ios - 如何在 Swift 中从本地视频 url 获取预览图像

ios - 如何使用 UINavigationController 强制设置横向方向(Swift 2.0 iOS 9)