OGeek|极客世界-中国程序员成长平台

标题: ios - UINavigationController supportInterfaceOrientations : category vs swizzle [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 06:28
标题: ios - UINavigationController supportInterfaceOrientations : category vs swizzle

我在我的 iPhone 应用程序中使用带有多个 UINavigationControllers 的 tabBarController,现在我想添加对旋转的支持(在某些 View Controller 上,不是全部)。我知道我需要为我的 UIViewControllers 实现 supportedInterfaceOrientation 方法。

当设备旋转时,在 UINavigationController 上调用了 supportedInterfaceOrientation,但我需要在我的 viewControllers 上调用它。最好的方法是什么?

任何建议表示赞赏。



Best Answer-推荐答案


如果您使用 iOS 6+,我建议继承 UINavigationController 并覆盖 supportedInterfaceOrientations

类似于:

- (NSUInteger)supportedInterfaceOrientations;
{
  return [self.topViewController supportedInterfaceOrientations];
}

关于ios - UINavigationController supportInterfaceOrientations : category vs swizzle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21866880/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4