【问题标题】:How remove UITabBarController from UIViewController如何从 UIViewController 中删除 UITabBarController
【发布时间】:2013-05-30 11:08:32
【问题描述】:

当我们使用UINavigationController 从一个UIViewController 移动到另一个UIViewController 时,如何从UIViewController 中删除UITabBarController

【问题讨论】:

  • 提问时请说的更详细。
  • 你的意思是隐藏标签栏吗?

标签: iphone ios uiviewcontroller uinavigationcontroller uitabbarcontroller


【解决方案1】:

覆盖代码中的init函数(loadView可能不起作用

self.hidesBottomBarWhenPushed = NO;

// 或者您可以通过将这些行放在 urself 命名的方法中,将其从应用程序委托中删除

[mainMenuTabBarController.view removeFromSuperview];

【讨论】:

    【解决方案2】:

    您应该将 UIViewController 的 this property 设置为 YES:BOOL hidesBottomBarWhenPushed

    例子: 下面代码的第二行就是你要问的。

    UIViewController *destinationVC = [[UIViewController alloc] init];
    [destinationVC setHidesBottomBarWhenPushed:YES]; // !!!
    [self.navigationController pushViewController:destinationVC animated:YES];
    

    【讨论】:

      【解决方案3】:
      [self.tabBarcontroller.view removeFromSuperview];
      

      【讨论】:

        【解决方案4】:
        [self.tabBarcontroller.view removeFromSuperview];
        [self.tabBarcontroller.tabbar removeFromSuperview];
        

        【讨论】:

          【解决方案5】:
          UIViewController *yourController = [[UIViewController alloc] init];
          [yourController setHidesBottomBarWhenPushed:YES]; 
          [self.navigationController pushViewController:yourController animated:YES];
          

          在这里你创建一个 ViewController 的实例,然后在推送它之前只需使用 setHidesBottomBarPushed() 以便在你推送它时隐藏它。

          但请记住,只有在推送之前执行此操作才会起作用。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2023-04-10
            • 1970-01-01
            • 1970-01-01
            • 2016-12-19
            • 1970-01-01
            • 1970-01-01
            • 2018-07-14
            • 1970-01-01
            相关资源
            最近更新 更多