Implementing estimatedHeightForRowAtIndexPath: causes the tableView to scroll down while reloading

ios, iphone, uitableview

Solution

So here's what i did to reduce the jumping while reloading the tableView.

In the `estimatedHeightForRowAtIndexPath:` I started returning a better estimated height. The more accurate the height is, lesser the jumping while adding new rows to the bottom.

I also started caching the calculated height of the cell from `heightForRowAtIndexPath:` in a dictionary and return the cached value the next time it calls the `estimatedHeightForRowAtIndexPath:`.

Hope this helps anyone who encounters this issue.

Problem

I've implemented 'infinite scrolling' on one of my projects and I was playing around with the new `estimatedHeightForRowAtIndexPath:` delegate method. Once I implemented that delegate method, my tableView jumps (a.k.a scroll to the bottom) whenever i call reloadData (which happens when i add a new set of rows.) Without that method, my tableView stays in place and it adds the additional rows to the bottom of the tableView without any scrolling. I'm calling the `[tableView reloadData]` and not the other methods (`insertRowsAtIndexPaths:`). I don't call the beginUpdates or endUpdates since I'm reloading the whole table. Has anyone experienced this ? I

Original source