使用故事板时,从UITabbarController添加/删除或显示/隐藏选项卡栏项 [英] Add/Remove or Show/Hide tab bar items from UITabbarController when using storyboards

查看:151
本文介绍了使用故事板时,从UITabbarController添加/删除或显示/隐藏选项卡栏项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序需要显示来自 UITabBarController 的不同内容,具体取决于用户是否已注册。有没有办法在运行时从 UITabBarController 添加和删除 ViewController ?显示和隐藏也很好。

I have an application that needs to show different content from a UITabBarController based on if the user is registered or not. Is there a way to add and remove ViewControllers from a UITabBarController at run-time? Show and Hide would be fine too.

在故事板之前,您可以调用 setViewController ,但这在使用stoaryboards时似乎不正确。

Prior to storyboards you could call setViewController but that does not seem to be the right way when using stoaryboards.

推荐答案

您可以删除标签栏项目,如下所示:

You can remove a tabbar item as follows:

NSMutableArray *tabbarViewControllers = [NSMutableArray arrayWithArray: [self.tabBarController viewControllers]];
[tabbarViewControllers removeObjectAtIndex: /*Any index*/];
[self.tabBarController setViewControllers: tabbarViewControllers ];

这篇关于使用故事板时,从UITabbarController添加/删除或显示/隐藏选项卡栏项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆