I have a scrollview with all my data to be showed and I want the user to trigger it being updated. The user should pull the scrollview downwards, then a small view will be shown that was previously hidden and that says: “updating” or “release to update”.
Look at the iPhone facebook app and you will see what I am talking about.
They did it pretty awesome, they have a small animation that and an arrow that makes it easy and intuitive.
However when trying to replicate this behaviour I have found that the UI is blocked until the scrollview delegate function was run. This is impractical because I want to update the UI from that scrollview delegate function.
So when the user holds the scrollview in a dragging motion, there should be a small animation or so that tells him to release it or hold it longer.
- (void) scrollViewDidScroll:(UIScrollView *)scrollView
{
CGPoint topOffset = CGPointMake(0, 20);
if (self.contentOffset.y < 0 )
{
labelUpdate.text = @"Release to update.";
//do something here to update the UI
}
}
Thanks for all the answers,
ultimately I have chosen this solution:
https://github.com/leah/PullToRefresh
because it simple and it works. Additionally I have refactored the ViewController shown there into a simple UIView type that you can comfortably use with any UIScrollView derived class.
A link with code will follow shortly.