簡體   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