これが解決策です。ビュー コントローラーの向きを管理する UINavigationController のカテゴリを追加できます。以下のコードを参照してください。
@interface UINavigationController (MyViewOrientations)
@end
@implemetation UINavigationController (MyViewOrientations)
- (BOOL)supportLandscapeModeForViewController:(UIViewController *)controller {
return [controller isKindOfClass:[LandscapeSupportViewController class]]
}
- (NSUInteger)supportedInterfaceOrientation {
UIViewController *controller = [self visibleViewController];
NSUInteger orientationMasks = UIInterfaceOrientationMaskPortrait
if([self supportLandscapeModeForViewController:controller]) {
orientationMasks |= UIInterfaceOrientationMaskLandscapeLeft;
orientationMasks |= UIInterfaceOrientationMaskLandscapeRight;
}
return orientationMasks;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
UIViewController *controller = [self visibleViewController];
if([self supportLandscapeModeForViewController:controller]) {
return UIInterfaceOrientationLandscapeLeft; // Your call
}
else {
return UIInterfaceOrientationPortrait;
}
}
- (BOOL)shouldAutorotate {
UIViewController *controller = [self visibleViewController];
return [self supportLandscapeModeForViewController:controller];
}
@end
状況がより複雑な場合、さまざまなビューがさまざまな方向性をサポートします。ビューコントローラーで「supportedInterfaceOrientation」、「preferredInterfaceOrientationForPresentation」、「shouldAutorotate」をオーバーライドし、UINavigationController カテゴリコードからの呼び出しを「visibleViewController」でデリゲートできます。