swift - 如何删除具有自定义选项卡 UI 的 UITabBarController 中的 "More"选项卡(不使用选项卡栏)

标签 swift uitabbarcontroller

我使用 UITabBarController 作为支持来呈现多个 View Controller ,但我没有使用底部的默认选项卡栏供用户点击选项卡。相反,我从左侧呈现一个滑出式菜单,它在表格 View 中显示选项卡列表。因此用户可以点击表格 View 中的一个单元格并切换到该选项卡。这是一种非常常见的显示多个 View Controller 选项卡的范例,无需使用 UITabBarController 底部的选项卡栏。

现在我已经添加了更多选项卡,但我的其中一个选项卡打开到 UITabBarController 的“更多” Controller 时遇到了问题。我不需要或不想要这个“更多” Controller ,因为我在可滚动列表中显示我的选项卡,而不是在空间有限的选项卡栏中。

如何删除“更多”选项卡或告诉我的 UITabBarController 不要显示“更多”屏幕?是否有一些选项可以禁用此功能?

最佳答案

解决方法:找到隐藏更多导航栏的正确时机。将这些代码添加到 UITabBarController 的子类中:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    if (self.viewControllers.count > 5)
    {
        self.moreNavigationController.delegate = self;
    }
}

在导航委托(delegate)回调中:

- (void)navigationController:(UINavigationController *)navigationController
  willShowViewController:(UIViewController *)viewController
                animated:(BOOL)animated

{
   navigationController.navigationBarHidden = YES;
}

关于swift - 如何删除具有自定义选项卡 UI 的 UITabBarController 中的 "More"选项卡(不使用选项卡栏),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51800591/

相关文章:

ios - 如何从多个导航 Controller 切换到一个 View Controller ,并在完成后返回到 swift 呈现的任何一个 View Controller

ios - UITapGestureRecognize 和 UILabel 在函数中获取标签文本

json - Realm +数据重复

objective-c - 从更多标签栏应用程序禁用编辑按钮

ios - UITabBarController 没有响应

iphone - 如何显示不属于 UINavigationController 根目录的 UITabBar?

ios - 找不到合并 @Published - Xcode11 Beta 5(11M382q)

ios - Swift 模拟器文件夹位置

iphone - 如何获取插入我当前 View 的上一个 View Controller

ios - 如何删除 UITabBar 上的图标