我目前正在尝试使用UITabBar作为一个包含7个tabBar项的iOS应用程序。
当我使用故事板时,我能够实现所有的7 tabBarItems。当我以编程方式添加tabBarItems时,它会强制一个“更多”按钮来访问另一个tabBarItems。
是否有一种以编程方式将所有7 tabBarItems保持为手动创建UITabBar的方法?

在我的应用程序中用来构建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];发布于 2014-04-29 01:39:11
从设计上看,你只能从苹果文档中获得5份。
如果向viewControllers属性添加了多个项,选项卡条控制器将自动插入一个特殊的视图控制器(称为“更多的视图控制器”)来处理附加项的显示。多视图控制器提供了一个自定义接口,该接口列出表中的附加视图控制器,该视图控制器可以展开以容纳任意数量的视图控制器。更多的视图控制器不能自定义或选择,并且不会出现在由选项卡条控制器管理的任何视图控制器列表中。当需要时,它会自动出现,并且与您的自定义内容分开。但是,您可以通过访问moreNavigationController属性UITabBarController来获得对它的引用。
它只是不建议使用,但是如果您坚持要使用一个库,或者可能需要使用一个工具栏并向其中添加许多UIBarButtonItems。
https://stackoverflow.com/questions/23353930
复制相似问题