I've got a pull-to-refresh feature in my app that is, as far as I can tell, set up the "normal way":
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull to Refresh"];
[refreshControl addTarget:self action:@selector(refreshPage) forControlEvents:UIControlEventValueChanged];
self.refreshControl = refreshControl;
The refreshing part works fine. After it is done refreshing I call
[self.refreshControl endRefreshing]
at which point, it appears to ignore that call and continues to show the pull-to-refresh "gap", only without the spinner:
(I do have a breakpoint at that line to verify that endRefreshing
IS actually being called)
If I jiggle the page with my thumb (pull it down slightly without pulling it far enough to trigger another pull-to-refresh), it will fix itself and spring back into place. But why doesn't it spring back when I call [self.refreshControl endRefreshing]
? Is there a way I can programmatically force it to spring back?
I've also tried placing the endRefreshing
call in a delay:
[self.refreshControl performSelector:@selector(endRefreshing) withObject:nil afterDelay:0.0]
but it still ignores the call.
For me setting
UITableView contentOffset
to zero, workedIn Swift 3.0
It turns out, in my case, the problem was that the code for adding the
UIRefreshControl
was being hit more than once and creating more than one refreshControl, soendRefreshing
was being called on a different instance ofUIRefreshControl
than the one that started the pull-to-refresh.Dumb mistake on my part.
After call
refreshControl.endRefreshing()
propertyisRefreshing = false
, but it can still be presented. Problem is in layers - while other animation is in progress or view controller with refresh control is not visible (other vc is presented or key window changed to another one). The code below helped me to fix this problemYou could stop the
refreshControl
and reset thetableview
position with an animation