2012-10-18 43 views
1

我子类化的UINavigationController如下:的UINavigationController - 旋转发出iOS6的

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

-(BOOL)shouldAutorotate { 
    return self.topViewController.shouldAutorotate; 
} 

但是我来脱胶在初始方向不同其父推视图控制器。在我的情况下,父亲的观点是唯一的肖像:

-(BOOL)shouldAutorotate { 
    return NO; 
} 
-(NSUInteger)supportedInterfaceOrientations { 
    return UIInterfaceOrientationMaskPortrait; 
} 

但我希望推视图,使其仅景观 - 它只会表现为这样的后手动更改设备的方向。

-(BOOL)shouldAutorotate { 
    return YES; 
} 
-(NSUInteger)supportedInterfaceOrientations { 
    return UIInterfaceOrientationMaskLandscape; 
} 

我非常感谢任何人指出我在正确的方向。 (我只带了一个哈克的解决方案至今...)


编辑:

以下所示为如何我启动子类的UINavigationController

PortraitView *vc = [[PortraitView alloc] init]; 
    SubClassedNav *navController = [[SubClassedNav alloc] initWithRootViewController:vc]; 
    [navController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal]; 
    [self presentViewController:navController animated:YES completion:nil]; 

和我如何随后推一个新的观点:

LandscapeView *vc = [[LandscapeView alloc] init]; 
    [[self navigationController] pushViewController:vc animated:YES]; 
+0

我在我的应用程序中有一个完全相同的设置,它的工作原理与您的建议相同。你确定它是按照你的描述设置的吗?我唯一的想法是你在Info.plist中设置了哪些支持方向? – InsertWittyName

+0

感谢您的想法。 info.plist支持所有的方向,所以不幸的是我的错误似乎并不存在。如果你运行良好,我怀疑我在某个地方犯了个小错误。 –

+0

你是否仔细检查过你是否使用了你的分级导航控制器? – InsertWittyName

回答

0

仔细检查您的设置[window setRootViewController:controller]在AppDele门。

+0

检查,但没有快乐:( 你可能会发布/指向我一个正常运作的项目? –