모든 내비게이션 컨트롤러가 상단 뷰 컨트롤러를 존중하려면 카테고리를 사용할 수 있으므로 클래스 이름을 변경하지 않아도됩니다.
@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을지지하는 데 도움이됩니다.