iOS 雙擊tabbar刷新頁面


/*在繼承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 {

}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM