01『 OC 知识 』

在tabBarController模式下怎么对UIViewCon

2016-06-21  本文已影响164人  一个城市猎人
在该控制类里面写一个方法:
- (void)setDataSource{
tabview.dataSource = nil;
tabview.dataSource = self;
}

在AppDelegate.m中调用:
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
if(viewController.tabBarItem.tag == 3)
{
UINavigationController *navigationctr = (UINavigationController *)viewController;
SecondViewController *secvc = (SecondViewController *)navigationctr.topViewController;
[secvc setDataSource];
}
}

显示底部按钮显示数字:

- (void)addBadge {    
_message.tabBarItem.badgeValue = [NSString stringWithFormat:@"%ld",(long)[UserInfo getInstance].badgeNums];  
  if ([UserInfo getInstance].badgeNums == 0)
 {       
 _message.tabBarItem.badgeValue = nil;  
  }
}
上一篇 下一篇

猜你喜欢

热点阅读