单击一个选项卡时隐藏TabBar [英] Hide TabBar when clicked on one tab Item

查看:90
本文介绍了单击一个选项卡时隐藏TabBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有四个tabBarItem.当用户单击第一个选项卡项目时,选项卡栏应被隐藏.其他三个选项卡栏应出现.这可能吗?

I have four tabBarItems. When a user clicks on the first tab item the tab bar should be hidden. The other three tab bars should appear. Is this possible?

推荐答案

预先警告:这是对选项卡栏的不寻常处理.

Warning up front: this is an unusual handling of tab bars.

如果将UITabBarItem连接为IBOutlet,并且还连接UITabBarController的委托,则在方法tabBarController:didSelectViewController中:您可以测试用户是否点击了感兴趣的标签栏. ,您可以将其title属性设置为@",如果它有图像,则可以将其图像属性设置为nil.

If you hook up the UITabBarItem as an IBOutlet, and also hook up the UITabBarController's delegate, then in the method tabBarController:didSelectViewController: you can test to see if the user has tapped the tab bar you're interested in. If so, you can set it's title property to @"" and if it has an image you can set it's image property to nil.

这看起来有点奇怪-它会为您提供功能齐全的tabBarItem,基本上是透明的.

This will look sort of strange though - it will give you a fully functioning tabBarItem, that is basically transparent.

如果您确实希望tabBarItem消失,请通过将tabBarControllers.viewControllers属性重置为不包含要隐藏的viewController的数组,将其从tabBarController中移除.

If you really want the tabBarItem to disappear, remove it from the tabBarController, by resetting the tabBarControllers.viewControllers property to an array that does NOT contain the viewController you want to hide.

这篇关于单击一个选项卡时隐藏TabBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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