2014-02-18 11 views
-1

我有一個UITabBarController在Interface Builder中設置,它有五個選項卡。我希望第一個標籤能夠向左或向右旋轉,但所有其他標籤都不能旋轉,只能設置爲UIInterfaceOrientationPortrait如何讓我的第一個選項卡旋轉,而其他人不在我的iOS 7應用程序中?

我把這段代碼放在我的第二個選項卡的視圖控制器(一個不應該旋轉的)中,但它仍然有效。按照預期方式正確調用代碼,但屏幕仍然旋轉。任何想法,爲什麼這可能是?

- (NSUInteger)supportedInterfaceOrientations 
{ 
    if (self.tabBarController.selectedIndex == 0) 
    { 
     return UIInterfaceOrientationMaskAllButUpsideDown; 
    } 
    else 
    { 
     return UIInterfaceOrientationPortrait; 
    } 
} 

- (BOOL)shouldAutorotate 
{ 
    if (self.tabBarController.selectedIndex == 0) 
    { 
     return YES; 
    } 
    else 
    { 
     return NO; 
    } 
} 

回答

-1

通過繼承UITabBarController並在其中添加代碼來修復它。

相關問題