IOS tabbar 點擊刷新頁面

參考網上資料
.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刷新頁面

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章