I'm trying to add the UIRefreshControl
to my UIScrollView
, but the problem is that it's area is too small, so it's almost impossible for user to pull to the required level.
So is there a way to trigger the state of this control or change the length of the required pull gesture?
I know, that this control is new and there may be no straight way of achieving this, but maybe someone has found a hack?
Found a solution: make a delegate of your scrollView and in - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
refresh the control at some offset
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
if (scrollView.contentOffset.y < -70) {
[refreshControl beginRefreshing];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
[self handleRefresh:refreshControl];
});
}
}
Dispatch is made for not lagging the interface while getting info from server.
If you then update something in your UI, use dispatch_async(dispatch_get_main_queue(), ^{//update UI code});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With