我目前正在尝试使用UITabBar
对于包含 7 个的 iOS 应用程序tabBar
Items.
当我使用故事板时,我能够实现所有 7 个目标tabBarItems
。
当我以编程方式添加tabBarItems
,它强制“更多”按钮访问其他 tabBarItems。
有没有一种方法可以像我手动创建时一样以编程方式保留所有 7 个 tabBarItemsUITabBar
?
我用来在 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];
根据设计,您最多只能使用 5 个,来自 Apple 文档
如果向 viewControllers 属性添加五个以上的项目,
标签栏控制器自动插入特殊的视图控制器
(称为更多视图控制器)来处理
附加项目。更多视图控制器提供自定义界面
列出了表中的附加视图控制器,可以
扩展以容纳任意数量的视图控制器。更多视图
控制器无法自定义或选择,并且不会出现在任何
由选项卡栏控制器管理的视图控制器列表。它
需要时会自动出现,并且与您的系统分开
自定义内容。您可以通过访问来获得对它的引用
UITabBarController 的 moreNavigationController 属性。
只是不推荐,但如果您坚持,您将需要使用库或者可能使用工具栏并向其中添加许多 UIBarButtonItems。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)