UITabBar显示更多图标而不是"更多"选项

Arm*_*ves 0 iphone uitabbarcontroller ios

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

当我使用故事板时,我能够实现所有7 tabBarItems.当我以编程方式添加时tabBarItems,它会强制使用"更多"按钮来访问其他tabBarItems.

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

我在说什么的例子

我用来在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];
Run Code Online (Sandbox Code Playgroud)

med*_*eda 5

根据设计,您只能使用Apple文档中的5个

如果向viewControllers属性添加五个以上的项目,则选项卡栏控制器会自动插入一个特殊的视图控制器(称为"更多视图控制器")来处理其他项目的显示.更多视图控制器提供了一个自定义界面,该界面列出了表中的其他视图控制器,可以扩展以适应任意数量的视图控制器."更多"视图控制器无法自定义或选择,也不会出现在由选项卡栏控制器管理的任何视图控制器列表中.它在需要时自动显示,并与您的自定义内容分开.您可以通过访问UITabBarController的moreNavigationController属性来获取对它的引用.

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