Skip to content

Instantly share code, notes, and snippets.

@thomasbrueggemann
Created June 6, 2013 08:14
Show Gist options
  • Save thomasbrueggemann/5720061 to your computer and use it in GitHub Desktop.
Save thomasbrueggemann/5720061 to your computer and use it in GitHub Desktop.
A simple pull-to-refresh for UIScrollViews. Whenever the UIScrollView ist pulled into a minus offset range auf at least -80, a reload method is triggered. But only if the scroll offset was in a range >= 0 before. This avoids infinite loading loops.
- (void)scrollViewDidScroll:(UIScrollView *)sender
{
if (sender.contentOffset.y >= 0)
{
self.inZero = YES;
}
// if the user pulled into abyss ...
if (sender.contentOffset.y <= -80 && inZero == YES)
{
inZero = NO;
// ... load content new
[self reload];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment