动态更改 TabBar 时管理 TabBar 操作
我想知道如何管理动态变化的选项卡。
例如。我的主屏幕上有 4 个选项卡。当我单击第二个选项卡时。我现在有 5 个不同的选项卡。我知道如何动态添加它们,但我在管理单击它们时发生的情况时遇到了麻烦。
例如,主屏幕是我的第一个选项卡。
if (viewController == [self.tabBarController.viewControllers objectAtIndex:0]){
这将处理我对第一个选项卡的操作,但是当我单击第二个选项卡时更改选项卡时,我不希望我的第一个选项卡成为我的第一组选项卡中的第一个主页。有没有办法通过身份而不是索引号来管理选项卡栏点击?另一个例子是我的注销功能在第一组中是选项卡4,在第二组中是选项卡5。我不希望第二组中的第四个选项卡注销,目前它确实会导致它读取索引。
I am wondering how I can Manage tabs as they are changing dynamically.
For Example. On my Home screen I have 4 tabs. When I click the 2nd tab. I will now have 5 different tabs. I know how to add them dynamically but I am having troubles managing what happens when they are clicked.
For example Home screen is my first tab.
if (viewController == [self.tabBarController.viewControllers objectAtIndex:0]){
That will handle my actions for the first tab but when I change my tabs when I click the second tab I don't want my first tab to be the the first home page from my first set of tabs. Is there a way to manage tabbar click by identity and not by index number? Another example is my logout function is tabbar 4 in the first set and tab 5 in the second set. I dont want the the 4th tab in the second set to logout and currently it does cause it reads the index.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Mike,在我看来,你对 UITabBar 的要求太高了。然而,我遇到过客户想要动态标签栏的情况。在这种情况下,代表团是你最好的朋友。
UITabBarDelegate:
UITabBarControllerDelgate
这将让您管理当选项卡栏上出现某些内容时将执行的操作。
此外,您实际上可以通过更改视图控制器上的选项卡栏项目来更改选项卡栏上的图标,而无需将其删除,
我希望这对您有帮助。祝你好运!
Mike, it seems to me that you are asking too much for an UITabBar. How ever, I've been in your situation where a client wants a dynamic tab bar. Delegation is you best friend in this case.
UITabBarDelegate:
UITabBarControllerDelgate
this will let you manage the actions that will be done when something is up on the tab bar.
Also you can actually change the icon on a tab bar without removing it by changing the tab bar item on the view controller
I hope this helps you. Best of luck!