参考网上资料
.h文件
#import <UIKit/UIKit.h>
@interface TabbarRootViewController : UITabBarController<UITabBarControllerDelegate>
@end
.m文件
#import "TabbarRootViewController.h"
#import "NoticeTableViewController.h"
@implementation TabbarRootViewController
-(void)viewDidLoad{
[super viewDidLoad];
self.delegate=self;
}
-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
if (viewController.tabBarItem.tag==2) {
UINavigationController *navigation =(UINavigationController *)viewController;
NoticeTableViewController *notice=(NoticeTableViewController *)navigation.topViewController;
[notice refreshData];
}
}
//禁止tab多次点击
-(BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController{
UIViewController *tbselect=tabBarController.selectedViewController;
if([tbselect isEqual:viewController]){
return NO;
}
return YES;
}
@end
在NoticeTableViewController 中写好刷新方法。即可点击tab刷新页面