【问题标题】:How to Hide UITabbarController in iPhone如何在 iPhone 中隐藏 UITabbarController
【发布时间】:2012-10-29 11:07:57
【问题描述】:

我已经在我的应用程序中实现了 UITabBarController。它的代码如下:

MainCollection *mainView = [[MainCollection alloc] initWithNibName:@"MainCollection" bundle:nil];
    UINavigationController *mainNav = [[UINavigationController alloc] initWithRootViewController:mainView];

    mainView = (MainCollection *)mainNav.topViewController;
    mainView.managedObjectContext = self.managedObjectContext;

    ShowFavourites *showVC = [[ShowFavourites alloc] initWithNibName:@"ShowFavourites" bundle:nil];
    UINavigationController *showNav = [[UINavigationController alloc] initWithRootViewController:showVC];
    showNav.title=@"Favourites";
     self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    UITabBarController *tabBar = [[UITabBarController alloc] init];

    [tabBar setViewControllers:@[mainNav,showNav]];

    [self.window setRootViewController:tabBar];

    [self.window makeKeyAndVisible];


    return YES;

我的第一个屏幕是 MainCollection 我应该在这个视图中显示 tabBar。假设下一个视图是 SubCategory 但是当我导航到 SubCategory 时,在这个视图上我想隐藏 Tabbar 那么我该如何隐藏它或仅从 SubCategory 视图中删除它?

有什么想法吗?

提前致谢。

【问题讨论】:

  • 这是一个令人困惑的问题,请详细描述。
  • @Raj:请检查我编辑的答案

标签: iphone objective-c uitabbarcontroller


【解决方案1】:

这有一个非常简单的解决方案。你应该更加努力。 在要隐藏 UITabBar 的视图中,只需添加

self.hidesBottomBarWhenPushed = YES;

在此处访问 SO 本身的这些链接。你会很容易找到答案:-

Show/Hide TabBarController in iphone

How to hide uitabbarcontroller

How to Hide Tab Bar Controller?

Is it possible to hide the tabbar when a button is pressed to allow a full screen view of the content?

How to hide UITabBarController programmatically?

How to hide an iPhone Tab Bar?

【讨论】:

    【解决方案2】:

    无需隐藏标签栏,只需使用父导航控制器推送到子类别屏幕

    [self.tabBarController.navigationController pushViewController:subCategoryObj animated:YES]; 
    

    谢谢,

    【讨论】:

    • 这是不可取的,因为在推送的视图控制器中设置self.title 时,它不会更新导航控制器。另一个答案要好得多。
    猜你喜欢
    • 2011-04-20
    • 2010-09-22
    • 2011-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-10
    • 1970-01-01
    • 2017-05-16
    相关资源
    最近更新 更多