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

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条回答 默认 最新

  • 关注
    评论

报告相同问题?

悬赏问题

  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗