2011-05-31 22 views
0

我遇到了自動旋轉問題,這個問題在UINavitionViewController裏面,navigationViewcontroller在tabBarViewController裏面。UINavigationViewController中的UIInterfaceOrientation

我subclassed tabBarViewController。問題是interfaceorientation在tabViewController中的第一個視圖上工作正常,但是每當我推到另一個視圖時它都不起作用。

這是子類tabBarController

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    return YES; 
    if([self.selectedViewController isKindOfClass:[UINavigationController class]]){ 
     return [[(UINavigationController*)self.selectedViewController visibleViewController] shouldAutorotateToInterfaceOrientation:interfaceOrientation]; 
    } else { 
     return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation]; 
    } 
} 
+3

你不覺得你的函數總會返回YES嗎? – 2011-05-31 12:48:18

回答

0

您應該在UITabBarController內的UINavigationController內有UIViewController。輪換由您的UIViewController中的shouldAutorotateToInterfaceOrientation:決定。您需要爲每個UIViewController重寫該方法以返回所需的值,即,如果您希望它旋轉,請輸入YES,如果不需要,輸入NO

您不應該在UINavigationControllerUITabBarController中覆蓋shouldAutorotateToInterfaceOrientation:

0

代碼,您必須覆蓋shouldAutorotateToInterfaceOrientation:在視圖控制器在標籤欄的所有意見。

如果視圖控制器的shouldAutorotateToInterfaceOrientation:返回NO,那麼即使視圖在旋轉時隱藏,標籤欄也不會旋轉。

相關問題