2012-11-14 42 views
1

我有一個標籤欄視圖控制器,其中包含一些導航控制器,每個都有一個根視圖控制器。所有東西都只能以肖像呈現。一切都很好。其中一個子視圖控制器使用它的導航vc推動另一個視圖控制器,並且我希望允許旋轉到其上。如何在tabbar中允許vc的vc自動轉換?

Tabbar vc 
    nav vc/vc1 
    nav vc/vc2 
    nav vc/vc3 
     pushes new vc4 <- ONLY this one should autorotate. Further more, if you're in landscape mode in this vc and hit 'back', it goes back in portrait. 

應用程序的'行'這樣做 - 實際的'聊天'窗口可以自動旋轉。

請給我代碼! ;)我希望它不需要搞亂變換...

回答

1

爲了支持你的UITabBarController應用程序的自動旋轉,你需要在你的tabBarController上繼承視圖控制器的旋轉調用,並詢問當前呈現的視圖控制器是否他支持新的方向。在你的具體情況下,vc4會被問及他是否支持方向改變,所以標籤欄可以在被詢問時旋轉。

採取在看這個問題:tabBarController and navigationControllers in landscape mode, episode II

+0

差不多!這確實允許vc4旋轉到風景如我所願。然而,當我彈出vc4,vc3仍然在風景 - 無論如何,我可以強制它的肖像? – Colin

+0

嘗試調用[UIViewController attemptRotationToDeviceOrientation] – J2theC

+0

是的!!!哦,等待iOS5。當怪異的業務約束! – Colin

0

@Colin在烏爾的TabBar視圖 - 控制,限制它potrait像

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

和UR新的視圖 - 控制(VC4),其限制在風景。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight)); 
} 

希望它有幫助。

+0

不起作用。首先嚐試。 – Colin

+0

只想問你如何在appdelegate中添加你的tabbarcontroller? bcoz它工作正常,如果你使用[self.window addSubview:tabbarcontroller.view]; – rehan