すべてのナビゲーションコントローラーがトップビューコントローラーを尊重するようにしたい場合は、カテゴリを使用して、クラス名を積んで変更する必要がないようにします。
@implementation UINavigationController (Rotation_IOS6)
-(BOOL)shouldAutorotate
{
return [[self.viewControllers lastObject] shouldAutorotate];
}
-(NSUInteger)supportedInterfaceOrientations
{
return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}
@end
コメントのいくつかが指摘しているように、これは問題の簡単な修正です。より良いソリューションは、サブクラスUinavigationControllerであり、これらの方法をそこに置きます。サブクラスは、6と7をサポートするのにも役立ちます。