解决方法
你试过viewWillTransitionToSize方法吗?这用于通知容器其视图的大小即将更改.
Objective-C的
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
迅速
func viewWillTransitionToSize(size: CGSize,withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) { coordinator.animateAlongsideTransition(nil,completion: { if UIDevice.currentDevice().orientation.isLandscape.boolValue { print("landscape") } else { print("portrait") } }