在UITableView與UICollection的時候可以透過滑動到最下面的時候去更新資料
透過UIScrollView的delegate來實現
- (void) scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
float bottomEdge = scrollView.contentOffset.y + scrollView.frame.size.height;
if (bottomEdge >= scrollView.contentSize.height) {
//更新資料的動作
[self callApi];
//呼叫loading畫面
[UIView animateWithDuration:0.5
delay:0
options:UIViewAnimationOptionAllowUserInteraction|UIViewAnimationOptionBeginFromCurrentState
animations:^{
self.endLoadingView.hidden = NO;
CGRect frame = self.endLoadingView.frame;
frame.origin.y += CGRectGetHeight(frame);
self.endLoadingView.frame = frame;
frame.origin.y -= CGRectGetHeight(frame);
self.endLoadingView.frame = frame;
}
completion:NULL];
}
}
沒有留言:
張貼留言