系统tabbar出现两个tabbar的问题解决方案。

先说说咋出来的, 扫描二维码成功后点击添加设备,直接pop to rootview    tabbar这个界面出现了如下问题

一开始觉得是扫描的时候出的问题, 查来查去发现界面一个个的返回不会出现问题, 如果两个界面以上在返回就出现这个问题。具体原因我没有深究, 无非就是苹果把系统自带的tabbar 给搞出来了, 那好我们直接上代码干掉苹果给我们 弄出来的tabbabr。

如下代码直接添加到这个vc中。

-(void)viewWillLayoutSubviews{

    

    [super viewWillLayoutSubviews];

    

    for (UIView *child in self.tabBar.subviews) {

        

        if ([child isKindOfClass:NSClassFromString(@"UITabBarButton")]) {

            

            [child removeFromSuperview];

            

        }

        

    }

    

}

- (void)viewWillAppear:(BOOL)animated{

    [super viewWillAppear:animated];

    for (UIView *child  in self.tabBar.subviews) {

        if ([child isKindOfClass:[UIControl class]]) {

            [child removeFromSuperview];

        }

    }

    

}

原文地址:https://www.cnblogs.com/godlovexq/p/5126221.html