边界上的 UIViewController 已更改

UIViewController on bounds changed

我需要一种方法来检测何时更改了 UIViewController 的边界(例如,当 phone 旋转时)

对于 UIView 我是这样做的:

 -(void)setBounds:(CGRect)newBounds

使用方法记录在 UIViewController class 参考的 "Handling View Rotations" 部分,

In iOS 8, all rotation-related methods are deprecated. Instead, rotations are treated as a change in the size of the view controller’s view and are therefore reported using the viewWillTransitionToSize:withTransitionCoordinator: method. When the interface orientation changes, UIKit calls this method on the window’s root view controller. That view controller then notifies its child view controllers, propagating the message throughout the view controller hierarchy.