美文网首页01『 OC 知识 』
在tabBarController模式下怎么对UIViewCon

在tabBarController模式下怎么对UIViewCon

作者: 一个城市猎人 | 来源:发表于2016-06-21 09:27 被阅读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;  
  }
}

相关文章

网友评论

    本文标题:在tabBarController模式下怎么对UIViewCon

    本文链接:https://www.haomeiwen.com/subject/coqgdttx.html