2011-05-02 53 views
5

我已經添加了一個自定義標籤欄。包含更多選項卡的選項卡。標籤欄界面方向問題

我的第一個標籤僅支持肖像模式。 第二個選項卡具有所有方向。

選擇第二個選項卡並將其保持橫向模式,然後在橫向模式下選擇第一個選項卡時會發生問題。那時,第一個選項卡視圖乾淨地旋轉,但選項卡欄保持橫向模式。

我該如何克服這種情況? 這是應在自定義標籤欄控制器旋轉方法

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
if (self.selectedIndex == 0) { 

    return [self.selectedViewController shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortrait]; 

} else if (self.selectedIndex == 1) { 

    return YES; 
} 

return NO;} 

這是在導航控制器

首先第一和第二視圖控制器應該旋轉方法

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

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
return YES;} 
+0

保持橫向的標籤欄是自定義的嗎?你是如何添加到屏幕上的? – 2011-05-02 10:48:59

+0

@Terente Ionut Alexandru \t \t navigationController_ = [[UINavigationController alloc] initWithRootViewController:tabBarController_]; \t [self.window addSubview:navigationController_.view]; – xydev 2011-05-03 08:48:32

回答

3

In should autorotate to int您需要重新繪製tabBar,然後將其從self.window中刪除並重新添加。

[navigationController_.view removeFromSuperview]; 
[self.window addSubview:navigationController_.view]; 

編輯:您需要設置正確的框架爲每個方向之前重繪。

+0

無話...它工作正常... :) +1 – xydev 2011-05-03 11:15:36

+0

再次感謝.. – xydev 2011-05-03 11:22:26