Ios6 SetViewController未基于topViewController设置正确的方向

Ios6 SetViewController未基于topViewController设置正确的方向,ios6,uiviewcontroller,uinavigationcontroller,rotation,Ios6,Uiviewcontroller,Uinavigationcontroller,Rotation,我使用UINavigationController在我的应用程序中显示内容。我将我的控制器保存在一个单独的字典中,在用户交互时,我用适当的UIViewController加载导航控制器。每个视图控制器实现 - (BOOL)shouldAutoRotate; 及 但当我尝试将视图控制器设置为导航控制器时,如下所示: [self setViewControllers:[NSArray arrayWithObject:controller] animated:NO]; 应用程序不会根据控制器支持

我使用UINavigationController在我的应用程序中显示内容。我将我的控制器保存在一个单独的字典中,在用户交互时,我用适当的UIViewController加载导航控制器。每个视图控制器实现

- (BOOL)shouldAutoRotate; 

但当我尝试将视图控制器设置为导航控制器时,如下所示:

[self setViewControllers:[NSArray arrayWithObject:controller] animated:NO];
应用程序不会根据控制器支持的方向旋转

例如,手机是横向的,“我的视图”控制器仅支持纵向。 如何使设备旋转到纵向

代码: 我的导航控制器子类

- (BOOL)shouldAutorotate{
    return [[self topViewController] shouldAutorotate];
}


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


- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentatio{
    return [[self topViewController] preferredInterfaceOrientationForPresentation];
}
我的控制器:

- (BOOL)shouldAutorotate{
    return YES;
}


- (NSUInteger)supportedInterfaceOrientations{    
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
        return UIInterfaceOrientationMaskPortrait;
    }
    return UIInterfaceOrientationMaskAll;
}


- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
    return UIInterfaceOrientationPortrait;
}
文档说明,为了调用supportedInterfaceOrientations,shouldAutorotate必须返回YES

有什么想法吗

- (BOOL)shouldAutorotate{
    return YES;
}


- (NSUInteger)supportedInterfaceOrientations{    
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
        return UIInterfaceOrientationMaskPortrait;
    }
    return UIInterfaceOrientationMaskAll;
}


- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
    return UIInterfaceOrientationPortrait;
}