在我的 rootViewController 中,我重新实现了shouldAutorotateToInterfaceOrientation
这样的方法。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
switch (toInterfaceOrientation) {
case UIInterfaceOrientationPortrait:
NSLog(@"Orientation - Portrait");
break;
case UIInterfaceOrientationLandscapeLeft:
NSLog(@"Orientation - Left");
break;
case UIInterfaceOrientationLandscapeRight:
NSLog(@"Orientation - Right");
break;
case UIInterfaceOrientationPortraitUpsideDown:
NSLog(@"Orientation - UpsideDown");
break;
default:
break;
}
return YES;
}
当我旋转我的设备时,会为 LandscapeRight、LandscapeLeft 和 UpsideDown 调用此方法,但不会为纵向方向调用此方法。
在启动时视图处于纵向模式,并且使用 UIInterfaceOrientationPortrait 调用此方法。但是,当我旋转设备时,不仅会为此方向调用此方法。