-1

我無法在通用應用程序中更改界面方向。它有一個導航控制器。我在導航控制器中添加了視圖控制器,並將導航控制器的視圖添加到窗口中。如果我移除導航控制器並將視圖控制器的視圖作爲子視圖添加到窗口,則它會識別方向,但如果添加導航控制器的視圖,則界面方向不會更改。請幫我參考一下。以下是我的代碼。 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {界面方向不會自動更改

if ([self.view isKindOfClass:[UINavigationController class]]) { 
    UIViewController *rootController = [((UINavigationController*)self.view).viewControllers objectAtIndex:0]; 
     return [rootController shouldAutorotateToInterfaceOrientation:interfaceOrientation]; 
    } 
return YES; 

} 
+2

請幫助我們通過在您的問題中包含相關代碼來爲您提供幫助。 – 2012-02-09 20:09:28

回答

2

一定要重寫- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation方法。默認情況下,UIViewController只爲縱向模式返回yes。

+0

謝謝。所以你的意思是我應該重寫此方法的UINavigationController.Can我得到任何參考? – jessy 2012-02-10 14:41:57