newDeveloper
newDeveloper

Reputation: 1365

Implementing estimatedHeightForRowAtIndexPath: causes the tableView to scroll down while reloading

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

Upvotes: 3

Views: 1991

Answers (3)

Georg
Georg

Reputation: 3930

I filed a BugReport quite a while ago (16472265) and today got the response that it's fixed in iOS8. Tried it out and it works now as expected. No more jumping of the tableview! Wohoooo

Upvotes: 2

newDeveloper
newDeveloper

Reputation: 1365

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.

Upvotes: 6

Vineesh TP
Vineesh TP

Reputation: 7963

Check your condition in this scrollView Delagete method,

-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate

Upvotes: 0

Related Questions