navigationBar显示混乱

时间:2015-11-03 02:55:14

标签: ios objective-c iphone

我创建了一个UINavigationController的子类,就像这个

@interface CustomNav : UINavigationController
@property(assign , nonatomic) BOOL canBack;
@end 

@implementation CustomNav
- (void)viewDidLoad {
    [super viewDidLoad];

    self.canBack = YES;
    // Do any additional setup after loading the view.
    id target = self.interactivePopGestureRecognizer.delegate;
    UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc] 
initWithTarget:target action:@selector(handleNavigationTransition:)];
    pan.delegate = self;
    [self.view addGestureRecognizer:pan];
    self.interactivePopGestureRecognizer.enabled = NO;
}

-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
//    NSLog(@"self.childViewControllers.count = %li",self.childViewControllers.count);
    if (self.childViewControllers.count==1||!self.canBack) {
        return NO;
    }
    return YES;
}
@end

但是当我使用它来推送viewController时,navigationBar显示已经解开,例如,它有一个viewController,然后它会推送另一个B viewController,但有时,它不会显示B的navigationItem,它只是显示A的navigationItem,然后我把C推到CustomNav,它也显示了A.的navigationItem。我不知道为什么,我发现它似乎是CustomNav显示B(或C)的navigationItem,然后是导航栏由A的navigationItem覆盖。每个人都可以帮助我吗?非常感谢你。

0 个答案:

没有答案
相关问题