Xcode6.1 iOS8  导航控制器popToRootViewController
我自定义了一个tabBarController 系统的tabbar上面的UITabbarButton 删了, 吧自定义的tabbar加在了系统的tabbar上面,开始运行正常, 但是当使用PopToRootViewController  时, tabbar上系统自带的UITabBarButton又出现了。。求解啊。。
/**
 *  删除系统自带的tabbarButton
 */
- (void)removeSystemTabBarItem
{
    for (UIView *subView in self.tabBar.subviews) {
        if ([subView isKindOfClass:[UIControl class]]) {
            subView.hidden = YES;
            [subView removeFromSuperview];
        }
    }
}
在tabbarController 删除了运行正常, 但是当 执行完
[self.navigationController popToRootViewControllerAnimated:YES];
后就出现了这种叠加的这种情况。

解决方案 »

  1.   

    求大神解答, 我应该在那个方法里删除系统自带的UITabbarButton勒
      

  2.   

    先试试如下的方式来隐藏tabbar, 替换掉你的removeSystemTabBarItem方法
    [self.tabBar setHidden:YES]; 
      

  3.   

    不会吧,这个方法应该是好用的。不行你再试试将你的removeSystemTabBarItem 方法放到viewWillAppear 中来调用。
      

  4.   

    ViewControllerA *A = (ViewControllerA*)[self.navigationController.viewControllers objectAtIndex:self.navigationController.viewControllers.count-2];    [self.navigationController popToViewController:A animated:YES];
      

  5.   

      NSArray *viewControllers = @[self.navigationController.viewControllers.firstObject,self.navigationController.viewControllers.lastObject];
            self.navigationController.viewControllers = viewControllers;
            [self.navigationController popViewControllerAnimated:YES];
    方法二:
    //        [self.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
    //            [self.navigationController popViewControllerAnimated:YES];
    //        }];
      

  6.   

    思路:在返回根视图调用方法PopToRootViewController之后,删除自定义的tabBar.[self.navigationController popToRootViewControllerAnimated:YES];
    [self removeSystemTabBarItem];- (void)removeSystemTabBarItem
    {
        for (UIView *subView in self.tabBar.subviews) {
            if ([subView isKindOfClass:[UIControl class]]) {
                [subView removeFromSuperview];
            }
        }
    }
      

  7.   

    真垃圾,提交后不能编辑。思路:返回根视图后popToRootViewController,删除系统的的tabBar.[self.navigationController popToRootViewControllerAnimated:YES];
    [tabBarController removeSystemTabBarItem];- (void)removeSystemTabBarItem
    {
        for (UIView *subView in self.tabBar.subviews) {
            if ([subView isKindOfClass:[UIControl class]]) {
                [subView removeFromSuperview];
            }
        }
    }