首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UITabBarItem显示/隐藏

UITabBarItem显示/隐藏
EN

Stack Overflow用户
提问于 2012-03-16 18:44:35
回答 1查看 542关注 0票数 0

早上好,我正在试着隐藏一个UITabBarItem,在读了很多帖子后,我快疯了……我可以正确地获取tabItem,但是它不能隐藏。我在故事板中设置我的TabBar。

这是我尝试过的3个选项中的code..none。

任何帮助我们都将不胜感激。

代码语言:javascript
复制
@implementation unidaAppDelegate

@synthesize window = _window;
@synthesize tabBarController = _tabBarController;


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 
    self.tabBarController = [storyboard instantiateViewControllerWithIdentifier:@"myTab"];

    NSMutableArray *tabs = [NSMutableArray arrayWithArray:self.tabBarController.viewControllers];
    NSLog(@"Array:%@",tabs);


    /*
    OPTION 1

    NSMutableArray *viewControllersCopy = [[self.tabBarController viewControllers] mutableCopy];
    [viewControllersCopy removeObjectAtIndex:2];
    NSArray *modifiedViewControllers = [[NSArray alloc] initWithArray:viewControllersCopy];
    [self.tabBarController setViewControllers:modifiedViewControllers animated:NO];

    OPTION 2

    NSMutableArray *modifyMe = [[self.tabBarController.tabBar items] mutableCopy];
    [modifyMe removeObjectAtIndex:2];
    NSArray *newItems = [[NSArray alloc] initWithArray:modifyMe];
    [self.tabBarController.tabBar setItems:newItems animated:true];


    OPTION 3

    NSLog(@"TabBarItem: %@",[[self.tabBarController.tabBar.items objectAtIndex:2] title]);
    [[self.tabBarController.tabBar.items objectAtIndex:2] setEnabled:FALSE];
     */

    sleep(1); 
    return YES;
}
EN

回答 1

Stack Overflow用户

发布于 2012-03-16 20:12:55

如果你使用的是Xcode4.x,试着选择你想要嵌入到tabBarController中的UIviews,然后选择go to Editor>Embed in>标签栏控制器。我这样做,效果会更好。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9735825

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档