【问题标题】:UITabBar Showing More Icons Instead of "More" OptionUITabBar 显示更多图标而不是“更多”选项
【发布时间】:2014-04-29 01:23:22
【问题描述】:

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

当我使用情节提要时,我能够实现所有 7 个tabBarItems。 当我以编程方式添加 tabBarItems 时,它会强制“更多”按钮访问其他 tabBarItems。

当我手动创建UITabBar 时,有没有办法以编程方式保留所有 7 个 tabBarItems?

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

  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];

【问题讨论】:

  • 你能添加你的代码吗?

标签: ios iphone uitabbarcontroller


【解决方案1】:

根据设计,您限制为 5 个,来自 Apple 文档

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

只是不推荐,但如果你坚持你将需要使用库或者可能使用工具栏并向其中添加许多 UIBarButtonItems。

【讨论】:

  • 谢谢,我只是想看看一些关于这个的额外想法。我有点喜欢这个库:link
  • @ArmYourselves 不错,这个真的很棒
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-03
  • 2021-07-26
  • 2013-10-01
  • 1970-01-01
  • 2021-02-12
  • 1970-01-01
相关资源
最近更新 更多