iOS 雙擊tabbar重新整理頁面,iostabbar重新整理頁面
/*在繼承UITabBarController控制器中*/
#pragma mark <UITabBarControllerDelegate>
-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
if ([self doubleClick]) {
UINavigationController *navigation =(UINavigationController *)viewController;
if ([navigation.topViewController respondsToSelector:@selector(tabbarDoubleClick)]) {
[navigation.topViewController performSelector:@selector(tabbarDoubleClick)];
}
}
}
/*判斷是否是雙擊(因為系統並沒有提供雙擊的方法, 可以通過點擊的時間間隔來判斷)*/
- (BOOL)doubleClick {
NSDate *date = [NSDate date];
if (date.timeIntervalSince1970 - self.lastDate.timeIntervalSince1970 < 0.5) {
//完成一次雙擊後,重設第一次單擊的時間,區分3次或多次的單擊
self.lastDate = [NSDate dateWithTimeIntervalSince1970:0];
return YES;
}
self.lastDate = date;
return NO;
}
#prama mark - 實現代理方法
/*在需要重新整理的介面*/
- (void)tabbarDoubleClick {
}