使用推送隐藏标签栏

Sid*_*shi 21 uitabbarcontroller uinavigationcontroller pushviewcontroller swift

我有一个tabBar+ NavigationViewController.选项卡栏具有带单元格的集合视图(Say view1),单元格中的push seague实现到另一个视图(Say view2).

view2中我想要一个navBar但没有标签栏.

我试过了

self.tabBarController?.tabBar.hidden = true,

它适用于view2但是当我通过后退按钮返回view1时,选项卡仍然被隐藏(即使在我在viewDidLoad func中添加的view1类中).self.tabBarController?.tabBar.hidden = false

如何让标签栏重新出现在view1中

我在迅速工作.

rck*_*nes 33

viewDidload设置UIViewController hidesBottomBarWhenPushed为yes:

self.hidesBottomBarWhenPushed = YES;
Run Code Online (Sandbox Code Playgroud)

这样就UINavigationController可以隐藏标签栏.

  • 如果它有效,你可能想接受我的答案 (3认同)

Tiz*_*tta 29

在此输入图像描述

尝试在你的控制器上检查这个!

  • 伟大的!很好又简单。确保仅在您希望隐藏其标签栏的 ViewController 上选中此选项。谢谢 :) (2认同)

Bru*_*uno 25

在prepareforsegue中使用

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"showRecipeDetail"]) {
    NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
    RecipeDetailViewController *destViewController = segue.destinationViewController;
    destViewController.recipeName = [recipes objectAtIndex:indexPath.row];

    // Hide bottom tab bar in the detail view
    destViewController.hidesBottomBarWhenPushed = YES;
}}
Run Code Online (Sandbox Code Playgroud)

=)


Mr *_*nev 21

Bruno Fernandes在Swift中的回答:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if segue.identifier == "YourSegueIdentifier" {
        let destinationController = segue.destinationViewController as! YourViewController
        destinationController.hidesBottomBarWhenPushed = true
    }
}
Run Code Online (Sandbox Code Playgroud)

这个答案对我有用.把hidesBottomBarWhenPushedviewDidLoad方法不起作用.

谢谢布鲁诺!


Rez*_*avi 9

就我而言,我hidesBottomBarWhenPushed在推送目标视图控制器之前使用。

func showSecondViewController() {
  let vc = SecondViewController()
  vc.hidesBottomBarWhenPushed = true
  self.navigationController?.pushViewController(vc, animated: true)
}
Run Code Online (Sandbox Code Playgroud)


归档时间:

查看次数:

20986 次

最近记录:

7 年 前