如何在推送视图时隐藏 tabBar?

发布于 2024-12-24 02:30:41 字数 226 浏览 1 评论 0原文

我的应用程序是一个选项卡式应用程序,它在 tabBarController 下有几个控制器。一个控制器是一个navigationController,它的根视图是一个表视图。当我单击表视图的一行时,将推入另一个视图。 那么问题来了,当view推入的时候,如何隐藏底部的tabBar呢? 另外,我还想在推送视图中添加另一个tabBar,所以我需要分配一个UITabBar或UITabBarController?或者还有别的办法吗?谢谢你!

My application is a Tabbed Application, and it have several controllers under the tabBarController. One controller is a navigationController, and its root view is a table view. When I click a row of the table view, another view will be pushed in.
So the question is that when the view is pushed in, how can I hide the tabBar at the bottom?
Besides, I also want to add another tabBar into the pushed view, so I need to alloc a UITabBar or UITabBarController? Or there is another way? Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

暗喜 2024-12-31 02:30:41

在要隐藏 tabBarController

-(BOOL)hidesBottomBarWhenPushed
{
    return YES;
}

Update

的 UIViewController 类中使用这种方法正如 @Yuchenzhong 在他的回答中所建议的,这个选项现在在故事板本身中可用。

输入图像描述这里

use this methood in the UIViewController class where you want to hide the tabBarController

-(BOOL)hidesBottomBarWhenPushed
{
    return YES;
}

Update

As suggested by @Yuchen Zhong in his answer, This option is now available in the storyboard itself.

enter image description here

兮子 2024-12-31 02:30:41

您现在可以在故事板中执行此操作:

  1. 在故事板中选择 UIViewController
  2. 选择复选框推送时隐藏底部栏

在此处输入图像描述

You can do this in storyboard now:

  1. Select the UIViewController in your storyboard
  2. Select the checkbox Hide Bottom Bar on Push

enter image description here

长发绾君心 2024-12-31 02:30:41

当你想隐藏标签栏时,设置UIViewController.hidesBottomBarWhenPushed = YES

nextViewController.hidesBottomBarWhenPushed = YES;

Set UIViewController.hidesBottomBarWhenPushed = YES when you want hide tab bar.

nextViewController.hidesBottomBarWhenPushed = YES;
酷炫老祖宗 2024-12-31 02:30:41

有时, hidesBottomBarWhenPushed 方法会隐藏带有断断续续的动画的底部栏。

相反,我隐藏 viewDidLoad 中的选项卡栏

self.tabBarController.tabBar.hidden = YES;

并在 viewWillDisappear 中恢复其存在

self.tabBarController.tabBar.hidden = NO;

Sometimes the hidesBottomBarWhenPushed method hides the bottom bar with a choppy animation.

Instead I hide the tabbar in viewDidLoad with

self.tabBarController.tabBar.hidden = YES;

and restore its presence in viewWillDisappear

self.tabBarController.tabBar.hidden = NO;
苏璃陌 2024-12-31 02:30:41

在要隐藏的控制器中设置 true hidesBottomBarWhenPushed

为了隐藏所有放入准备segue的控制器

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    segue.destination.hidesBottomBarWhenPushed = true
}

Set true hidesBottomBarWhenPushed in the controller that you want to hide.

For hide all controllers put into prepare for segue

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    segue.destination.hidesBottomBarWhenPushed = true
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文