Вот что я использовал:
Прежде всего, у вас есть представление, содержащее сообщение «Подтянуть для обновления», и назначьте его для:
[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;
}
}
}
В конце верните contentInset tableView, чтобы скрыть pullUpView.