2011-03-01 17 views
1

嘿傢伙, 我想自動旋轉我的標籤欄應用程序。顯然,我知道大多數人會說這個問題是return YES;或所有標籤欄項目必須在同一個類中才能自動旋轉。不,它不適合我。首先,我有4個選項卡欄項目,每個項目都有自己的類別。我的第一個2選項卡欄項目有UIWebViews,第二個是表視圖和最後一個是帶有按鈕的圖像視圖。現在,我練貫徹我的第一個標籤欄項目,這是一個使用此代碼,因爲return YES;,我沒有工作,一個UIWebView自動旋轉代碼:自動旋轉標籤欄應用程序

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
     // Return YES for supported orientations. 
     return (interfaceOrientation == UIInterfaceOrientationPortrait); 
     if (interfaceOrientation == UIInterfaceOrientationPortrait || 
      interfaceOrientation == UIInterfaceOrientationLandscapeLeft || 
      interfaceOrientation == UIInterfaceOrientationLandscapeRight) 
      return YES; 
     else 
      return NO; 
} 

使用此代碼沒有標籤欄爲我工作,但當使用Tab Bar應用程序時,它不適用於我。同樣,當程序員告訴我所有其他Tab Bar應用程序必須具有相同的Class文件時,我不能這樣做,因爲我的Tab Bar中的每個都有自己的Class文件,就像我之前說過的那樣。

所以希望,有人能幫助我這種情況,以自動旋轉整個標籤欄,感謝

回答

3

您需要在使用TabBar返回YES所有視圖控制器。


而且你的代碼可以更短,僅此:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 
} 
+0

所以嘿,我還有一個問題,我的UIWebView是一個移動網站,當我把它旋轉到左邊,應用程序的整體尺寸完全移到左側,任何想法如何到這個網站移到當它自動向左或向右旋轉時中間? – PatrickGamboa 2011-03-01 17:49:02

+0

'body {width:200px;保證金:0汽車; }'? – 2011-03-01 18:35:20

1

大家都知道,你這個方法在第一線返回YES(在縱向方向的情況下)或者NO?

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
     // Return YES for supported orientations. 
     return (interfaceOrientation == UIInterfaceOrientationPortrait); 
    // this never gets called: 
    // if (interfaceOrientation == UIInterfaceOrientationPortrait || 
    //  interfaceOrientation == UIInterfaceOrientationLandscapeLeft || 
    //  interfaceOrientation == UIInterfaceOrientationLandscapeRight) 
    //  return YES; 
    // else 
    //  return NO; 
} 
相關問題