UITabBar显示更多图标而不是“更多"图标.选项 [英] UITabBar Showing More Icons Instead of "More" Option

查看:65
本文介绍了UITabBar显示更多图标而不是“更多"图标.选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试将UITabBar用于包含7个tabBar项目的iOS应用.

I'm currently attempting to use the UITabBar for an iOS app that contains 7 tabBar Items.

使用情节提要时,我可以实现全部7个tabBarItems. 当我以编程方式添加tabBarItems时,它将强制使用更多"按钮来访问其他tabBarItems.

When I use the storyboard, I am able to achieve all 7 tabBarItems. When I programmatically add the tabBarItems, It forces a "More" Button to access the other tabBarItems.

有没有办法像我手动创建UITabBar时一样以编程方式保留所有7个tabBarItem?

Is there a way programmatically keep all the 7 tabBarItems as when I am manually create the UITabBar?

我用于在appdelegate.m中构建uitabbar的代码

The Code that I'm using to build the uitabbar in my appdelegate.m

  self.tabBarController = [[UITabBarController alloc] init];
  FirstViewController *firstVC = [[FirstViewController alloc] init];
  SecondViewController *secondVC = [[SecondViewController alloc] init];
  ThirdViewController *thirdVC = [[ThirdViewController alloc] init];
  FourthViewController *fourthVC = [[FourthViewController alloc] init];
  FifthViewController *fifthVC = [[FifthViewController alloc] init];
  SixthViewController *sixthVC = [[SixthViewController alloc] init];
  SeventhViewController *seventhVC = [[SeventhViewController alloc] init];

  NSArray *controllers = @[firstVC, secondVC, thirdVC, fourthVC, fifthVC, sixthVC, seventhVC];

  self.tabBarController.viewControllers = controllers;
  self.window.rootViewController = self.tabBarController;
  [_window addSubview:_tabBarController.view];

推荐答案

根据设计,苹果文档的用户数限制为5个

By design you are limited to 5, from apple docs

如果您在viewControllers属性中添加了五个以上的项目, 标签栏控制器自动插入特殊的视图控制器 (称为更多视图"控制器)来处理 其他项目. More视图控制器提供了一个自定义界面 在表格中列出了其他视图控制器, 扩展以容纳任意数量的视图控制器.更多视图 不能自定义或选择控制器,并且不会出现在任何控制器中 标签栏控制器管理的视图控制器列表的列表.它 会在需要时自动显示,并且与您的 自定义内容.您可以通过访问 UITabBarController的moreNavigationController属性.

If you add more than five items to the viewControllers property, the tab bar controller automatically inserts a special view controller (called the More view controller) to handle the display of the additional items. The More view controller provides a custom interface that lists the additional view controllers in a table, which can expand to accommodate any number of view controllers. The More view controller cannot be customized or selected and does not appear in any of the view controller lists managed by the tab bar controller. It appears automatically when it is needed and is separate from your custom content. You can get a reference to it though by accessing the moreNavigationController property of UITabBarController.

不建议这样做,但是如果您坚持要使用库,或者使用工具栏并向其中添加许多UIBarButtonItems.

It just not recommended , but if you insist you will need to use a library or perhaps use a tool bar and add many UIBarButtonItems to it.

这篇关于UITabBar显示更多图标而不是“更多"图标.选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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