Select no tabs in a UITabBar(在 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.
不要问我为什么,这就是客户想要的!呵呵
Don't ask me why, it's just that way the client wants it! hehe
感谢您的帮助!
PS:我已经试过了:
// 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];
有什么想法吗?再次感谢!
Any ideas? Thanks again!
推荐答案
如果你使用的是没有 UITabBarController 的 UITabBar 实例,你可以取消选择所有标签栏项目.
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.'
换句话说,如果您想完成这项工作,您需要在没有控制器的情况下手动管理标签栏的例程.
In other words if you would like to get this worked you need to manage tabbar's routines manually without controller.
这篇关于在 UITabBar 中不选择任何选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 UITabBar 中不选择任何选项卡
基础教程推荐
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- iOS4 创建后台定时器 2022-01-01
