在UITabBar中不选择选项卡 [英] Select no tabs in a UITabBar

查看:685
本文介绍了在UITabBar中不选择选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中尝试不选择任何标签。首先,选择第一个标签,但我要取消选择,因此不会选择任何标签。

I'm trying to select no tabs at all in my application. At first the first tab is selected, but I'd like to deselect it so no tabs at all would be selected.

不要问我为什么,只是方式客户想要它! hehe

Don't ask me why, it's just that way the client wants it! hehe

感谢您的帮助!

PS:我已经尝试过:

PS: I already tried:

// rootController = UITabBarController    
rootController.tabBar.selectedItem = 0;
rootController.tabBar.selectedItem = nil;
[rootController setSelectedIndex:[rootController.items objectAtIndex:0]];
[rootController setSelectedIndex:nil];
[rootController setSelectedIndex:0];
// That one works : (but I can't select 0 or -1 for instance)
[rootController setSelectedIndex:2];

任何想法?

推荐答案

如果您使用的UITabBar实例没有UITabBarController,您可以取消选择所有标签栏项目。

You can deselect all tab bar items if you are using UITabBar instance without UITabBarController one.

在这种情况下,以下代码工作良好。

In such case below code works well.

[tabBar setSelectedItem:nil];

如果UITabBar是UITabBarController的一部分,那么应用程序将崩溃,例外:

If UITabBar is a part of UITabBarController then application will crash with exception:


通过标签栏控制器直接修改选项卡栏
不允许

'Directly modifying a tab bar managed by a tab bar controller is not allowed.'

换句话说,如果你想得到这个工作,你需要手动管理tabbar的例程没有控制器。

In other words if you would like to get this worked you need to manage tabbar's routines manually without controller.

这篇关于在UITabBar中不选择选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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