薇姐的男人 2019-12-28 10:51 采纳率: 0%
浏览 1032

ios 导航栏设置隐藏后无效的问题

基本框架是用的UITabBarController+UINavigationController,在AppDelegate中添加了四个tab页
在tab页中,点击跳转二级页面是,设置隐藏导航栏,确始终会显示,不知道是哪里错了,有大佬能指点一二吗

AppDelegate中初始化代码:

HomeVC *homeVC = [[HomeVC alloc] init];
    FindVC *findVC = [[FindVC alloc] init];
    WorkRoomVC *workVC = [[WorkRoomVC alloc] init];
    MineVC *mineVC = [[MineVC alloc] init];

    UINavigationController *navHome = [[UINavigationController alloc]initWithRootViewController:homeVC];
    UINavigationController *navFind = [[UINavigationController alloc]initWithRootViewController:findVC];
    UINavigationController *navWork = [[UINavigationController alloc]initWithRootViewController:workVC];
    UINavigationController *navMine = [[UINavigationController alloc]initWithRootViewController:mineVC];

        UITabBarController *tabBar = [[UITabBarController alloc] init];
    [tabBar addChildViewController:navHome];
    [tabBar addChildViewController:navFind];
    [tabBar addChildViewController:navWork];
    [tabBar addChildViewController:navMine];

    tabBar.tabBar.translucent = NO;
    tabBar.delegate = self;
    self.window.rootViewController = tabBar;


在HomeVC中点击跳转:

SearchVC *vc = [[SearchVC alloc] init];
        vc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vc animated:YES];

SearchVC中设置不显示导航栏:

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = YES;
    [self.navigationController setNavigationBarHidden:YES];
}

图片说明

  • 写回答

1条回答

  • 关注
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘