如何在需要的地方显示和隐藏标签栏?

发布于 2024-11-19 00:17:40 字数 426 浏览 1 评论 0原文

您好,我正在制作一个应用程序,其中有从 1 到 4 的四个屏幕(视图控制器)。我想显示没有选项卡栏的屏幕 1。该屏幕将具有三个按钮,用户可以通过它们导航到其他屏幕。现在,当用户点击屏幕 2 按钮时,用户应导航到底部带有选项卡栏的屏幕 2。现在,此选项卡栏将有从屏幕 1 到屏幕 4 的四个选项卡进行导航。同样,当用户现在点击选项卡 1 时,屏幕 1 应该到达这是没有标签栏等。 我的问题是我无法在所需的位置加载或卸载选项卡栏。我尝试过以下操作:

  1. 我在 statrt up 上打开屏幕 1,并且在屏幕 1 的视图上确实加载了选项卡栏,但它不起作用
  2. 我添加了选项卡主窗口上的栏,但标签栏甚至开始显示在屏幕 1 上。

    请告诉我执行此操作的正确方法(换句话说,带有四个选项卡的选项卡栏,其中第一个屏幕不应显示选项卡栏)

提前致谢

Hi i am making an application where ther are four screens(view controllers) from 1 to 4. I want to show screen 1 without tab bar .This screen will have three buttons through which user can navigate to other screens. Now when user taps screen 2 button then user should navigate to screen 2 with tab bar on bottom.Now this tab bar will have four tabs from screen 1 to 4 to navigate .Similarly when now user tap on tab 1 then the scrren 1 should arrive which is without tab bar and so on.
My problem is i am not able to load or unload tab bar at required places.I have tried following:

  1. I opened screen 1 on statrt up and on screen 1's view did load added the tab bar but it didnt work
  2. I added tab bar on main window but then tab bar starts to show even on screen 1.

    PLease tell me the correct way to do this (In other words a tab bar with four tabs in which the first screen should not show tab bar)

Thanks in advance

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

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

发布评论

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

评论(2

沧笙踏歌 2024-11-26 00:17:40

使用这一行

self.hidesBottomBarWhenPushed=YES;

隐藏标签栏。在推送您想要隐藏选项卡栏的页面之前使用此命令,并

self.hidesBottomBarWhenPushed=No;

在您要推送 viewWillDisappear 的同一页面上写入此行。

use this single line

self.hidesBottomBarWhenPushed=YES;

for hide tab bar. use this before push the page where you want tab Bar hidden and also write this line

self.hidesBottomBarWhenPushed=No;

at same page from where you are going to push in viewWillDisappear.

嘿看小鸭子会跑 2024-11-26 00:17:40
self.window.rootViewController = self.navigationController;

首先在窗口中添加 rootviewcontroller。
并在其中添加三个按钮。

在按钮的单击事件上将 tabbarcontroller 添加到主窗口

AppDelegate *delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
delegate.tCtr.selectedIndex = btntag;  //ur button tag;
delegate.tCtr.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:delegate.tCtr animated:YES];
self.window.rootViewController = self.navigationController;

First add your rootviewcontroller in the window.
and add three buttons in it.

on clicking event of button add tabbarcontroller to mainwindow

AppDelegate *delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
delegate.tCtr.selectedIndex = btntag;  //ur button tag;
delegate.tCtr.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:delegate.tCtr animated:YES];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文