Question

I have added a message count using the MKNumberBadgeView via the following code in my uiTableView Homepage -

-(void)counterBtn{

    _numberBadge = [[MKNumberBadgeView alloc] initWithFrame:CGRectMake(25, -10, 40, 40)];
    _numberBadge.strokeColor = [UIColor colorWithRed:239.0/255.0 green:117.0/255.0 blue:33/255.0 alpha:0];
    _numberBadge.fillColor = [UIColor colorWithRed:239.0/255.0 green:117.0/255.0 blue:33/255.0 alpha:1];
    _numberBadge.shine = NO;
    _numberBadge.hideWhenZero = YES;
    _numberBadge.value = _countBtnNo;
    [self.navigationController.navigationBar addSubview:_numberBadge];

}

All works fine - but if I navigate from this view to a subview the counter is still shown over the back button as in screenshot -

enter image description here

Is it possible to temporarily hide this button - then show it again when I return to the homepage?

I was thinking something along these lines in the subview's viewdidload method? -

[self.navigationController.navigationBar.subviews setHidden:YES];
Était-ce utile?

La solution

Try this in HomeScreen:

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    _numberBadge.hidden = NO;
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    _numberBadge.hidden = YES;
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top