2012-10-18 41 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

檢查,但沒有快樂:( 你可能會發布/指向我一個正常運作的項目? –