objective-c - 我在哪里可以设置 UINavigationControllers supportedOrientations?

标签 objective-c uinavigationcontroller ios6

我使用的是 iOS 6.0 beta,但我的旋转功能不再有效。

我在哪里可以设置 UINavigationControllers supportedOrientations?

根据这个http://news.yahoo.com/apple-ios-6-beta-3-changes-182849903.html UINavigation Controller 不会咨询他们的 child 来确定他们是否应该自动旋转。

我不再使用 shouldAutorotateToInterfaceOrientation:,因为它已被弃用。 相反,我使用 supportedInterfaceOrientations: 和 shouldAutoRotate: 并且它们工作正常,直到我将 ViewController 放入 NavigationController(作为子级)。 从那时起,ViewController 中指定的方向不再起作用。 它似乎正在使用导航 Controller (UIInterfaceOrientationMaskAllButUpsideDown) 设置的方向

如何为 NavigationController 设置 InterfaceOrientations,以便我的 ViewControllers 锁定为纵向方向?

我是否必须继承 UINavigationController 并在那里设置 InterfaceOrientations?在 iOS 6.0 中继承 UINavigationController 不是不好的做法吗?

谢谢你的帮助堆!

干杯!

最佳答案

如果你想让它再次咨询它的 child ,你可以向 UINavigationController 添加一个类别

@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

关于objective-c - 我在哪里可以设置 UINavigationControllers supportedOrientations?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12169517/

相关文章:

uinavigationcontroller - 使用导航 Controller 和搜索显示 Controller 时 MonoTouch SIGSEGV 崩溃

ios - 如何找出哪个类(class)插入了我?

ios - 使用 Storyboard 本地化 UIViewController

iphone - 如何将值传递给父 View Controller ?

ios - 在基于ARC的APP中释放内存?

iphone - WebCore 在 NSOperationQueue 操作中崩溃

objective-c - 从一个 UICollectionViewLayout 切换到另一个时的自定义动画?

objective-c - 添加自定义按钮到数字键盘 ios 6

ios - navigationItem setRightBarButtonItems 间距太宽

ios - 使用媒体查询检测 Mobile Safari 全屏模式