i have tab bar controller, has 3 view controller attached.
say start app, first view controller view out of other 3 loaded. want set badge value of third view controller isn't loaded. because want user know have notifications when open app.
is possible , how can it? have tried following:
calling view ( 1 want change badge ) class:
notificationsviewcontroller *class = [notificationsviewcontroller alloc]init]; [class view]; then, in notificationsviewcontroller class, set badge 1 if app has notifications using parse:
- (void)viewdidload { [super viewdidload]; pfinstallation *currentinstallation = [pfinstallation currentinstallation]; if (currentinstallation.badge > 0) { nsstring *badge = @"1"; [self.tabbaritem setbadgevalue:badge]; } } why isn't working? how can change badge of view controller isn't loaded yet?
first, need tab bar item:
uitabbaritem *tabbaritem = [[self.tabbarcontroller.viewcontrollers objectatindex:your_index] tabbaritem]; then, set badge on it.
nsstring *badge = @"1"; [tabbaritem setbadgevalue:badge];
Comments
Post a Comment