Skip to content

Instantly share code, notes, and snippets.

@taylanpince
Created April 25, 2012 10:47
Show Gist options
  • Save taylanpince/2488911 to your computer and use it in GitHub Desktop.
Save taylanpince/2488911 to your computer and use it in GitHub Desktop.
Pull to Refresh
#pragma mark - Scroll View Delegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
[super scrollViewDidScroll:scrollView];
if (_refreshInProgress) return;
if (self.tableView.contentOffset.y > 50.0 && self.tableView.contentOffset.y < 140.0) {
if (self.tableView.contentOffset.y <= 90.0) {
[(RefreshView *)self.tableView.tableHeaderView displayInstructions];
} else {
[(RefreshView *)self.tableView.tableHeaderView hideInstructions];
}
}
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
[super scrollViewDidEndDragging:scrollView willDecelerate:decelerate];
if (self.tableView.contentOffset.y < 90.0) {
_refreshInProgress = YES;
[self.tableView setContentInset:UIEdgeInsetsMake(-100.0, 0.0, 0.0, 0.0)];
[(RefreshView *)self.tableView.tableHeaderView startLoading];
[self reloadData];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment