Ipad UITABBARC控制器和旋转iOS6

Ipad UITABBARC控制器和旋转iOS6,ipad,ios6,rotation,uitabbarcontroller,autorotate,Ipad,Ios6,Rotation,Uitabbarcontroller,Autorotate,美国人民的阵亡将士纪念日快乐 我不熟悉iOS和Objective-C编程;几周前,我继承了一款为iOS 5设计的正在开发中的iPad应用程序。现在,除了iOS 6中的轮换,我的一切都正常了。我知道iPad应用程序应该按默认方向旋转(这是我想要的),但我的应用程序却没有。在iOS 5中,一切都可以完美旋转,我可以让我的启动屏幕在iOS 6中完美旋转,但仅此而已。我无法使活动(一旦你点击启动屏幕)正确旋转 我已经搜索了stackoverflow和其他网站以了解我必须做什么,因此我知道在任何特定的Vi

美国人民的阵亡将士纪念日快乐

我不熟悉iOS和Objective-C编程;几周前,我继承了一款为iOS 5设计的正在开发中的iPad应用程序。现在,除了iOS 6中的轮换,我的一切都正常了。我知道iPad应用程序应该按默认方向旋转(这是我想要的),但我的应用程序却没有。在iOS 5中,一切都可以完美旋转,我可以让我的启动屏幕在iOS 6中完美旋转,但仅此而已。我无法使活动(一旦你点击启动屏幕)正确旋转

我已经搜索了stackoverflow和其他网站以了解我必须做什么,因此我知道在任何特定的ViewController中实现
-(BOOL)shouldAutorotate
-(nsuiger)supportedInterfaceOrientations
,以控制该视图的方向行为。我已经读到,在一个VC中有不同的旋转行为会影响整个应用程序。因此,我确保我能找到的每个VC现在都会实现这两个iOS 6方法,分别返回
YES
UIInterfaceOrientationMaskAll
。那没用。我读过关于在这些方法中返回
self.tabBarController.shoulldautorotate
self.tabBarController.supportedInterfaceOrientations
,以确保tabbar旋转行为一致,但这不起作用。我读过关于实现一个类别(UITabBarController+autoRotate.m和.h)的文章,它实现了这两种方法,但没有成功。我读过关于tabBarController子类化的文章,我认为我的代码就是这样做的:在appDelegate中,我调用

[myWindow setRootViewController:activityViewController]

其中activityViewController是BicycleFamilyAcitivityViewController类的实例,该类来自

@interface BicycleFamilyActivityViewController:UIViewController

当我使用iOS 6模拟器研究在成功的启动屏幕旋转过程中调用的内容时,我注意到正在调用BicycleFamilyAcitivityViewController中的这两个实现的方法(实际上每个调用两次),并且
-(void)WillAnimateRotationInterfaceOrientation:duration
也是如此。当我在查看活动时尝试旋转时(在点击启动屏幕后),这两个方法只调用一次,并且不会调用
-(void)WillAnimateRotationInterfaceOrientation:duration
。在这两种情况下,都会调用appDelegate的
-(nsInteger)application:SupportedInterfaceDirectionsforWindow
方法

关于如何在整个应用程序中实现轮换,有什么建议吗?即使它只是指向我还没有看到(或完全理解)的关于StackOverflow的答案,我也会非常感激

非常感谢

伯尼


************************************************************!在ViewController中,您的设置应如下所示:

-(NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationLandscapeRight;
}

-(BOOL)shouldAutorotate {
    return TRUE;
}

UIInterfaceOrientationMaskAll
是所有方向,更多信息

内部有人解决了这个问题。我想我会发布答案来帮助任何有类似困境的人

我尝试过的(除其他外)是:将appDelegate类中的UIWindow设置为UIViewController子类(BicycleFamilyAcitivityViewController)的实例。在我的appDelegate中,我有:

[myWindow setRootViewController:activityViewController];
其中activityViewController是UIViewController子类的实例

但我应该通过委托创建一个额外的UIWindow,然后在构建TabBarController时将TabBarController(tbc)指定为根VC。在我的主视图控制器类中,我有一个
buildTabBarController
函数。所以函数中的这两行允许我旋转:

UIWindow *keyWindow = [[[UIApplication sharedApplication] delegate] window];
[keyWindow setRootViewController:tbc];

希望这有帮助

谢谢John,我已经在ViewController中实现了这些方法,除了preferredInterfaceOrientationForPresentation。我在每个viewController中添加了该方法,以防它是差异制造者。但事实并非如此。我知道单个ViewController没有shouldAutorotate&supportedInterfaceOrientations调用。我认为,如果我能让系统进行这些调用,一切都应该就绪(因为在iOS5中轮换工作非常完美)。还有其他建议吗?我还是会投票支持你的答案,因为这是一个正确的答案;但我需要一个15岁的名声才能做到这一点!我还没弄明白。我的rootVC(BicycleFamilyActivityViewController)中的shouldAutoRotate和supportedInterfaceOrientations方法在旋转时被调用,它们返回YES和UIInterfaceOrientationMaskAll,但这似乎不会旋转选项卡栏或任何东西。我可以从这些方法写出对子视图控制器中相应方法的调用,但这没有帮助。不幸的是,系统在旋转时不会调用Category函数。加载viewController时调用支持的InterfaceOrientations函数;不应该叫自动旋转。