繁体   English   中英

如何在UITabBarController中添加9个或更多选项卡?

[英]How to add 9 or more tab to UITabBarController?

在iPad中使用垂直选项卡时,似乎UITabBarController将tab的数量限制为8。
但我想显示9个或更多标签。

首先,我只将1~7个选项卡设置为UITabBarController,
并使用UITabBarController外部的第8和第9个选项卡作为以下源代码。
它显示9个选项卡,但会导致一些问题,例如工具栏损坏,旋转许可等等。

有没有办法正确显示9个或更多标签?

#define RT_TABMEMU_ITEM_MAX 8
#define RT_TABMEMU_ITEM_MAX_WITH_MORE 7

- (void)setSelectedViewController:(UIViewController *)selectedViewController {
    ...

// If the amount of viewController is less than 9, 
// or index of selectedViewController is 0~6, 
// set selectedViewController to UITabBarController
    if (!(RT_TABMEMU_ITEM_MAX < [self.viewControllers count]
          && RT_TABMEMU_ITEM_MAX_WITH_MORE <= [self.viewControllers indexOfObject:selectedViewController])) {
        [super setSelectedViewController:selectedViewController];
    }

    ...
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    UIViewController *selectedController = (self.viewControllers)[indexPath.row];

    if (self.selectedViewController != selectedController) {
        [self setSelectedViewController:selectedController];

    ...

我建议你试试InfiniTabBar for iOS开源项目。 有了它,您可以添加任意数量的选项卡。 我在自己的项目中使用它,它非常好!

祝一切顺利!

它是根据PUBLIC LICENSE或作者所说的许可证发布的:

与往常一样,我的所有源代码都可以免费使用到您的应用中。 如果您的应用程序是开源的,请确保不要从源代码中删除版权声明。 你没有必要在我的应用程序中归我,尽管如果你这样做我会很高兴的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM