如何限制UITabBarController上的选项卡数量? [英] How to limit the number of tabs on a UITabBarController?

查看:181
本文介绍了如何限制UITabBarController上的选项卡数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有UITabBarController的iPhone应用程序。一切正常。该应用程序有更多的选项卡,可以在显示器的纵向宽度上显示,因此我们总共看到5个选项卡(最后一个是更多选项卡)。问题是,我们希望将一些不太有趣的东西放在更多标签背后。我知道如果我只有2个视图控制器,那么我只会看到2个标签,依此类推,直到我超过5个标签。

I have a working iPhone app with a UITabBarController. It all works fine. The app has more tabs than can be shown across the portrait width of the display, so we see 5 tabs in total (the last being the "more" tab). The thing is, we want to relegate some of the "less interesting" things to be behind the "more" tab. I know that if I had just 2 view controllers, then I'd see just 2 tabs, and so on until I exceeded 5 tabs.

我们怎样才能显示4个标签(3加上更多标签),而不是5?

How can we show just 4 tabs (3 plus a "more" tab), instead of 5?

我的猜测是:只有设置属性才能实现这一点(这当然很方便! ),因为我在文档中找不到任何内容,或者坦率地说,在其他方面建议。

My guess is: this is not possible by just setting an attribute (which would certainly be convenient!), since I cannot find anything in the docs, or here frankly, to suggest otherwise.

没有实现我自己的更多选项卡,并提供标签栏控制器只有4个视图控制器(最后一个是我自己的更多控制器),任何提示,技巧或提示都表示赞赏。谢谢!

Short of implementing my own "more" tab, and supplying the tab bar controller with only 4 view controllers (the last being my own "more" controller), any tips, tricks, or hints are appreciated. Thanks!

推荐答案

只是想把它包起来。最后,我实现了自己的更多控制器,并为UITabBarController提供了4个视图控制器,最后一个是我的更多控制器。

Just wanted to wrap this up. In the end, I implemented my own "More" controller, and supplied the UITabBarController with just 4 view controllers, the last being my More controller.

自定义更多控制器是我创建UITabBarController的主要选项卡和相关控制器时创建的通用UITableViewController子类。然后,我将行标题和相应的UIViewControllers添加到更多视图控制器中的数组。当该标签可见并点击一行时,我只需按下相应的视图控制器。

The custom More controller is little more than a generic UITableViewController sub-class that I create when I create the UITabBarController's main tabs and associated controllers. I then add row titles and corresponding UIViewControllers to an array in the More view controller. When that tab is visible and a row is tapped, I just push the appropriate view controller.

整个效果看起来完全是库存,除了我有4个标签而不是这也不像我想象的那样麻烦。永远是奖金。

The whole effect looks totally "stock", except I have 4 tabs instead of 5. It was less of a hassle than I thought it would be to implement, as well. Always a bonus.

希望这可以帮助有人下线。

Hope this helps someone down the line.

这篇关于如何限制UITabBarController上的选项卡数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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