IPhone projects need the Pull to Update feature

Many iPhone projects use the "Pull-to-Refresh" template to download more results (usually this is new data from the server.

In my project, I want to do just the opposite: "pull-up to refresh". I want to load old data from the server, but I need the user to request data by pulling up the UITableView.

How can i do this? Can anybody help me?

+5
source share
3 answers

Here is what I used:

First of all, you have a view containing the message β€œPull up to update the message” and assign it:

[pullUpView setFrame:CGRectMake(0, [tableView rectForFooterInSection:0].origin.y, [tableView bounds].size.width,pullUpView.frame.height)];

, , .

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {    
    if (scrollView.isDragging) {
        CGFloat thresholdToRelease = [pullUpView frame].origin.y - [scrollView bounds].size.height;
        CGFloat thresholdToLoad = thresholdToRelease + [pullUpView frame].size.height;

        if (([scrollView contentOffset].y >= thresholdToRelease) && ([scrollView contentOffset].y < thresholdToLoad)) {
            [pullUpView reset];
        } else if ([scrollView contentOffset].y >= thresholdToLoad) {
            [pullUpView indicateThresholdRearched];
        }
    }
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
    CGFloat thresholdToAction = [pullUpView frame].origin.y + [pullUpView frame].size.height - [scrollView bounds].size.height;

    if ([scrollView contentOffset].y >= thresholdToAction) {
        if (!performingAction) {

            [pullUpView startLoading];

            [UIView beginAnimations:nil context:NULL];
            [UIView setAnimationDuration:0.5];
            [tableView setContentInset:UIEdgeInsetsMake(0, 0, [pullUpView frame].size.height, 0)];
            [UIView commitAnimations];

            /* do your things here */
            performingAction = YES;
        }
    }
}

tableViewInset, pullUpView.

+8

" , " , . , Three20 . "pull up to refresh", .

0

All Articles