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