在检测方向变化并对其使用react时,我看到了两种方法:实现 willRotateToInterfaceOrientation 或要求 View 开始发出相关通知 (deviceOrientationDidChange
) .
什么时候打算使用后者?有什么好处?
最佳答案
willRotateToInterfaceOrientation:duration:
方法是 UIViewController 的一部分。如果您是从 UIViewController 派生的,则只需重写此方法即可获知方向更改。
但是,如果您在其他类(class)并希望了解方向变化,那么您需要注册 UIDeviceOrientationDidChangeNotification .
关于ios - willRotateToInterfaceOrientation 和 deviceOrientationDidChange 之间有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6758115/