0

I was able to access without problem to a particular "tab" from appDelegate with this code:

 UIStoryboard *mainStoryBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UINavigationController  *myView = [mainStoryBoard instantiateViewControllerWithIdentifier:@"mailListID"];
    if (myView.tabBarItem.tag == 999)
        [myView.tabBarItem setBadgeValue:@"100"];

and how you can see from this screenshot:

Debug

I'm able to change the value of the badge from code (into appDelegate). But the result is that into the application the value not change! Seems like something needs to be refreshed!!!

Somebody could tell me why?!?

Blasco73
  • 2,980
  • 2
  • 24
  • 30
  • We probably would need the full code where you are changing the variable on the app delegate. – Jordan Nov 19 '14 at 18:05
  • Sorry.. This same code works fine into the viewController referred to "mailListID" but not update value into badge onto appDelegate. What full code you need?!? – Blasco73 Nov 19 '14 at 18:11
  • This is the code into ViewController that works: for (UIViewController *vc in self.tabBarController.viewControllers) { if (vc.tabBarItem.tag == 999) { vc.tabBarItem.badgeValue = @"100"; } } – Blasco73 Nov 19 '14 at 18:11
  • The section where it actually updates the app delegate. – Jordan Nov 19 '14 at 18:11
  • Ah ok... :D - (void)application:(UIApplication *)application didReceiveRemoteNotification: (NSDictionary *)userInfo { – Blasco73 Nov 19 '14 at 18:13
  • 2
    With that block of code you are not accessing the existing tab bar, but you are creating a new one, setting the badge and discarding it... You'll need some way to get to the existing one (property, nsnotification, etc...) – Fabio Ritrovato Nov 19 '14 at 18:23
  • Fabio seems italian!! :D So: avevo immaginato una cosa simile. (anche se per capire facevo il test sul tag=999 impostato all'interno del ViewController). Comunque ho aggirato il problema mettendo un observer all'interno del didReceiveRemoteNotification e così non ho necessità di aggiornarlo nel appDelegate. Grazie e ciao – Blasco73 Nov 19 '14 at 18:26

0 Answers0