我在哪里可以设置UINavigationControllers supportedOrientations? [英] Where can I set a UINavigationControllers supportedOrientations?

查看:150
本文介绍了我在哪里可以设置UINavigationControllers supportedOrientations?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iOS 6.0测试版,我的轮换不再有效了。

I am using iOS 6.0 beta and my rotations do not work anymore.

我在哪里可以设置UINavigationControllers supportedOrientations?

Where can I set a UINavigationControllers supportedOrientations?

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

According to this http://news.yahoo.com/apple-ios-6-beta-3-changes-182849903.html a UINavigation Controller does not consult their children to determine whether they should autorotate.

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

I am not using shouldAutorotateToInterfaceOrientation: anymore as it is deprecated. Instead I am using supportedInterfaceOrientations: and shouldAutoRotate: and they are working fine until I place a ViewController into a NavigationController (as a Child). From then on the orientations specified in the ViewController do not work anymore. It seems it is using the orientations set by the navigation controller (UIInterfaceOrientationMaskAllButUpsideDown)

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

How can I set the InterfaceOrientations for the NavigationController so that my ViewControllers are locked to Portrait-Orientation?

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

Do I have to subclass UINavigationController and set the InterfaceOrientations there? Isn't it bad practise to subclass UINavigationController still in iOS 6.0?

谢谢你帮助堆!

干杯!

推荐答案

如果你想再次咨询它的孩子,可以在UINavigationController中添加一个类别

If you want it to consult it's children again you can add a category to 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

这篇关于我在哪里可以设置UINavigationControllers supportedOrientations?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆