2015-04-14 199 views
0

我只是想知道我怎麼能隱藏在Tab Bar Controller標籤項目爲被選擇隱藏標籤

+0

如何在隱藏在當前視圖中時選擇其他選項卡? –

+0

你在Swift或ObjC工作嗎? – Wez

+0

@Wezly在ObjC工作 –

回答

1

首先當前視圖控制器,我不認爲這是可能隱藏UITabBarItem - 它從UIBarItem繼承,但沒有hidden財產 - UIBarItem Documentation

你可以嘗試比較標籤欄selectedViewController屬性與目前的視圖控制器? - 像下面的東西可能會工作..

if (self.tabBarController.selectedViewController == self) { 
    // Do Stuff 
} 

但即使如此,我認爲你會發現很難隱藏標籤欄項目本身。

+1

是的,閱讀更多。我認爲我的情況是最好的解決方案,一旦完成視圖控制器就完全刪除它。即登錄屏幕。 –

0
UIView *parent = self.tabBarController.tabBar.superview; // UILayoutContainerView 
    UIView *content = [parent.subviews objectAtIndex:0]; // UITransitionView 
    UIView *window = parent.superview; 

    [UIView animateWithDuration:0.2 
        animations:^{ 
         CGRect tabFrame = self.tabBarController.tabBar.frame; 
         tabFrame.origin.y = CGRectGetMaxY(window.bounds); 
         self.tabBarController.tabBar.frame = tabFrame; 
         content.frame = window.bounds; 
        }]; 
3

從控制器刪除預期的索引數組ex。 (1)

NSMutableArray *controllersArray = [NSMutableArray arrayWithArray:self.tabBar.viewControllers]; 
[controllersArray removeObjectAtIndex: 1]; 
[self.tabBar setViewControllers:controllers animated:YES]; 

檢查這個答案我也發現這個類似從你的問題Hide tab bar item and aligning other tab items 希望這有助於你。!