Last active
September 3, 2015 16:51
-
-
Save jberkman/8779769 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)refresh:(id)sender | |
{ | |
double delayInSeconds = 5.0; | |
UIRefreshControl * __weak refreshControl = self.refreshControl; | |
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); | |
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ | |
// Calling [self.refreshControl endRefreshing] while tableView is | |
// decelerating causes it to stop abruptly. performSelector:...afterDelay: | |
// defers this until after decelerating completes. | |
[refreshControl performSelector:@selector(endRefreshing) | |
withObject:nil | |
afterDelay:0]; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great, @jberkman!
Since you asked, @filblue – I like the original idea better.
It's ways more simple and depends on only one line of code, not an additional property, another method that needs to be called and so on.
I have to admit – before I came across this gist, I did it the same way than you.