用的系统的滑动返回,在滑动返回时遇到了这种情况, navigationItem也是自定义的

解决方案 »

  1.   

    由于你的navigationItem是自定义的,所以需要在不需要它的地方,清理掉;
    对于你的情况,在父ViewController的ViewDidAppear清理一下了
      

  2.   


    没明白,navgationItem不是应该一直存在的吗,如果清理调的话,是不是我点击操作的时候就不能用了啊,还有我不知道怎么清理
      

  3.   


    - (void)initNavigationItem
    {
        itemView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, BAR_BUTTON_H)] autorelease];
        backButton.frame = CGRectMake(MARGINSPACE, 0, backButton.frame.size.width, backButton.frame.size.height);
        [itemView addSubview:backButton];
        funcButton.frame = CGRectMake(itemView.frame.size.width - MARGINSPACE - funcButton.frame.size.width, 0, funcButton.frame.size.width, funcButton.frame.size.height);
        [itemView addSubview:funcButton];
        
        UIBarButtonItem *right = [[[UIBarButtonItem alloc] initWithCustomView:itemView] autorelease];
        // 调整 barButtonItem 在 iOS7以上的位置
        float margin = -5;
        if (isIOS7Above()) {
            margin = -16;
        }
        
        UIBarButtonItem *negativeSpacer = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
                                                                                         target:nil action:nil] autorelease];
        //这个数值可以根据情况自由变化negativeSpacer.width = -16;
        negativeSpacer.width = margin;
        [self.navigationItem setRightBarButtonItems:@[negativeSpacer, right]];
        
        [self.navigationItem setLeftBarButtonItems:@[negativeSpacer]];
        
        [itemView addSubview:titleView];
        
    }这是初始化的代码,你看下没问题吧,其他情况都没问题就是滑动返回时会出现这个问题