2

我正在使用没有控制器的 UITabBar。如果满足某些条件,我想从 UITabBar 中删除选项卡。例如,我的 UITabBar 在界面生成器中设置了 4 个选项卡。如果在编译时未启用分数模块,则应删除分数选项卡。

// defined in IB
#define kTabScores 1 
UITabBar *_tabBar;


// in viewDidLoad
#if !INCLUDE_SCORES_SUPPORT
    // this doesn't seem to work
    [[_tabBar viewWithTag:kTagScores] removeFromSuperview];
#endif
4

1 回答 1

4

您是否尝试过使用 的items属性UITabBar?例如:

// defined in IB
#define kTabScores 1 
UITabBar *_tabBar;


// in viewDidLoad
#if !INCLUDE_SCORES_SUPPORT
    NSMutableArray *newItems = [NSMutableArray arrayWithArray:_tabBar.items];
    [newItems removeObjectAtIndex:0]; //your index here.
    [_tabBar setItems:newItems animated:YES];
#endif
于 2010-05-04T19:26:13.487 回答