2015-04-14 203 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 希望这有助于你。!