【问题标题】:How to remove "more" option from tabbar controller without delete tabs in ios如何从标签栏控制器中删除“更多”选项而不删除ios中的标签
【发布时间】:2014-06-14 22:24:09
【问题描述】:

我正在使用选项卡栏控制器,当我在显示 4 个选项卡之后运行应用程序时,我有 6 个选项卡,并且有更多选项,但在这里我想显示所有不想在 ios 7 中显示“更多”的选项卡。代码是:

    UIViewController *viewController1 = [[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];

    Calendar *viewController2 = [[Calendar alloc] initWithNibName:@"Calendar" bundle:nil];

    nearby *viewController3 = [[nearby alloc] initWithNibName:@"nearby" bundle:nil];
    offer *viewController4 = [[offer alloc] initWithNibName:@"offer" bundle:nil];
    social *viewController5 = [[social alloc] initWithNibName:@"social" bundle:nil];
    contact *viewController6 = [[contact alloc] initWithNibName:@"contact" bundle:nil];



    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController1];
    UINavigationController *navController1 = [[UINavigationController alloc] initWithRootViewController:viewController2];
    UINavigationController *navController2 = [[UINavigationController alloc] initWithRootViewController:viewController3];
    UINavigationController *navController3 = [[UINavigationController alloc] initWithRootViewController:viewController4];



    self.tab = [[UITabBarController alloc] init];

    self.tab.viewControllers = [NSArray arrayWithObjects:navController, navController1,navController2,navController3,viewController5,viewController6, nil];
    [[self.tab tabBar] setBackgroundImage:[UIImage imageNamed:@"tabcrop.png"]];
  self.tab.customizableViewControllers = nil;
    [[[self.tab moreNavigationController] visibleViewController] setTitle:@""];

    [self.tab.tabBar setTranslucent:YES];
    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                       [UIFont fontWithName:@"AmericanTypewriter" size:10.0f], UITextAttributeFont,
                                                       [UIColor yellowColor], UITextAttributeTextColor,
                                                       [UIColor redColor], UITextAttributeTextShadowColor,
                                                       [NSValue valueWithUIOffset:UIOffsetMake(0.0f, 1.0f)], UITextAttributeTextShadowOffset,
                                                       nil] forState:UIControlStateSelected];
    self.window.rootViewController = self.tab;

`

【问题讨论】:

  • 为它使用自定义标签栏控制器。在普通标签栏中你不能这样做
  • 你不能那样做。你必须使用自定义控件。看到这个github.com/Marxon13/M13InfiniteTabBar
  • @Aakash 非常欢迎你。如果有帮助,请接受我的回答

标签: ios iphone ios7 uitabbarcontroller


【解决方案1】:

根据苹果的文档,这是不可能的:https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/ViewControllerCatalog/Chapters/TabBarControllers.html

它是这样说的:

如果在 viewControllers 属性中添加超过五个项目,标签栏控制器会自动插入一个特殊的视图控制器 (称为更多视图控制器)来处理 附加项目。 More 视图控制器提供自定义界面 列出表中的其他视图控制器,可以 扩展以容纳任意数量的视图控制器。更多视图 控制器无法自定义或选择,并且不会出现在任何 由标签栏控制器管理的视图控制器列表。它 需要时自动出现,并且与您的 自定义内容。

所以试试自定义标签栏试试这个: https://github.com/Marxon13/M13InfiniteTabBar

【讨论】: