Skip to content

Instantly share code, notes, and snippets.

@AKupetskiy
Last active December 4, 2018 05:17
Show Gist options
  • Save AKupetskiy/08bcd5ffb33e69a0b9f5db98f93f2b9b to your computer and use it in GitHub Desktop.
Save AKupetskiy/08bcd5ffb33e69a0b9f5db98f93f2b9b to your computer and use it in GitHub Desktop.
Fix: UITableView scrolls to top after method [tableView endUpdates]
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
CGPoint offset = tableView.contentOffset;
[tableView beginUpdates];
// do something
[tableView endUpdates]; //<- this method causes scrolling
[tableView.layer removeAllAnimations];
[tableView setContentOffset:offset animated:NO]; //<- Voilà! Now it works perfect :]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment