IOS double-click tabbar to refresh the page, and iostabbar to refresh the page

Source: Internet
Author: User

IOS double-click tabbar to refresh the page, and iostabbar to refresh the page

/* Inherit the 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)];

}

}

}

 

/* Determine whether it is double-click (because the system does not provide the double-click method, you can determine by clicking the interval )*/

-(BOOL) doubleClick {

 

NSDate * date = [NSDate date];

 

If (date. timeIntervalSince1970-self. lastDate. timeIntervalSince1970 <0.5 ){

 

// After a double-click is completed, reset the time of the first click to distinguish between three or multiple clicks.

 

Self. lastDate = [NSDate dateWithTimeIntervalSince1970: 0];

 

Return YES;

 

}

 

Self. lastDate = date;

 

 

Return NO;

 

}

# Prama mark-proxy Implementation Method

/* On the interface to be refreshed */

-(Void) tabbarDoubleClick {

}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.