美文网首页
iOS导航条从无到有切换问题

iOS导航条从无到有切换问题

作者: Operation | 来源:发表于2017-06-23 16:35 被阅读69次
    - (void)viewWillAppear:(BOOL)animated
    {
        [self.navigationController setNavigationBarHidden:YES animated:YES];
        [super viewWillAppear:animated];
    }
    
    -(void)viewWillDisappear:(BOOL)animated{
    
        [self.navigationController setNavigationBarHidden:NO animated:YES];
        [super viewWillDisappear:animated];
    }
    
    

    这样写有个问题,如果首页没有导航条,下一页有,切换tabbar的时候,这一页会有隐藏导航条的动画
    所以

    - (void)viewWillAppear:(BOOL)animated
    {
        
        [super viewWillAppear:animated];
        if (self.tabBarController.selectedIndex != 0) {
            [self.navigationController setNavigationBarHidden:YES animated:NO];
        }else{
            [self.navigationController setNavigationBarHidden:YES animated:YES];
        }
    }
    
    -(void)viewWillDisappear:(BOOL)animated
    {
        
        [super viewWillDisappear:animated];
        [self.navigationController setNavigationBarHidden:NO animated:YES];
    }
    

    应该加个判断

    相关文章

      网友评论

          本文标题:iOS导航条从无到有切换问题

          本文链接:https://www.haomeiwen.com/subject/subccxtx.html