robbdimitrov / RDVTabBarController

Highly customizable tabBar and tabBarController for iOS
MIT License
2.31k stars 501 forks source link

can't update badge #17

Closed StephenZhuang closed 10 years ago

StephenZhuang commented 10 years ago

I add a notification like this, - (void)refreshNum:(NSNotification *)notification,this method works , but the badge does't change;

robbdimitrov commented 10 years ago

Hi Stephen,

Sorry for the delay. The problem can be solved by calling [self setNeedsDisplay]; on the tab bar item after the change. Something like this:

- (void)setBadgeValue:(NSString *)badgeValue {
    _badgeValue = badgeValue;

    [self setNeedsDisplay];
}

I'll add this fix in the next version of RDVTabBarController.

StephenZhuang commented 10 years ago

@robbdimitrov Hi rob,thanks for reply. The solution above seems that does't work correctly. I select tab1 and post a notification as above, and in tab2 I observe the notification. if I don't select tab2, the badge of tab2 will not change or appear.

robbdimitrov commented 10 years ago

@StephenZhuang Hi Stephen, I've managed to inspect and fix the problem. I was setting parentViewController to nil when hiding a view controller. This resulted in a bug where rdv_tabBarController on a hidden controller returned nil value. The problem has been fixed in commit eb74eafcf609c753704cf60c67e43d9869fea4ea.