私の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に対して呼び出されますが、Portrait方向に対しては呼び出されません。
起動時、ビューはポートレートモードであり、このメソッドはUIInterfaceOrientationPortraitで呼び出されます。しかし、デバイスを回転させると、このメソッドはこの方向に対してのみ呼び出されるわけではありません。