Skip to content

Instantly share code, notes, and snippets.

@gmertk
Created May 12, 2015 15:16
Show Gist options
  • Save gmertk/fdafc803a6ff6b906200 to your computer and use it in GitHub Desktop.
Save gmertk/fdafc803a6ff6b906200 to your computer and use it in GitHub Desktop.
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (scrolledToBottomWithBuffer(scrollView.contentOffset, scrollView.contentSize, scrollView.contentInset, scrollView.bounds)) {
[self _enqueuePage:[_quoteModelController fetchNewQuotesPageWithCount:8]];
}
}
static BOOL scrolledToBottomWithBuffer(CGPoint contentOffset, CGSize contentSize, UIEdgeInsets contentInset, CGRect bounds)
{
CGFloat buffer = CGRectGetHeight(bounds) - contentInset.top - contentInset.bottom;
const CGFloat maxVisibleY = (contentOffset.y + bounds.size.height);
const CGFloat actualMaxY = (contentSize.height + contentInset.bottom);
return ((maxVisibleY + buffer) >= actualMaxY);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment