我在 iPhone 应用程序中使用带有多个 UINavigationController 的 tabBarController,现在我想添加对旋转的支持(在某些 View Controller 上,而不是全部)。我知道我需要为我的 UIViewController 实现supportedInterfaceOrientation 方法。
当设备旋转时,在 UINavigationController 上调用supportedInterfaceOrientation,但我需要在我的 viewControllers 上调用它。最好的方法是什么?
我看到有些人在 UINavigationController 上创建了一个类别,该类别覆盖了supportedInterfaceOrientation来查询子viewControllers。但我知道苹果不赞成使用类别来覆盖方法。 (我已经像这样实现了它,并且运行良好,但我想确保该应用程序继续与 future 版本的 iOS 一起使用。)
使用方法调配怎么样?
子类 UINavigationController?
任何建议表示赞赏。 :)
最佳答案
如果您使用iOS 6+,我建议子类化UINavigationController
并覆盖supportedInterfaceOrientations
类似于:
- (NSUInteger)supportedInterfaceOrientations;
{
return [self.topViewController supportedInterfaceOrientations];
}
关于ios - UINavigationController 支持的InterfaceOrientations : category vs swizzle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21866880/