You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Adding new cell while scrolling causes table view to jump #26
... the tableview jumps up before it continues scrolling from a random location. This doesn't happen if the tableview is not scrolling (i.e. it's stationary) when you add cells. I'm assuming this is another UITableView auto-sizing bug that has something to do with scrollView frame and offset calculations when the table view is being scrolled.
Anyone have any ideas for a workaround? I wanted to check before I try to get too clever.
It certainly seems like insertRowsAtIndexPath:withRowAnimation: is the problem here because it probably attempts to adjust scrollview height immediately but by using the estimatedRowHeight of the newly inserted rows.
Calling reloadData whenever a couple of cells are added certainly seems like a less than ideal workaround, so I'm still interested to see if anyone has better ideas.
This stops the tableView from scrolling and therefore prevents the glitch: tableView.setContentOffset(tableView.contentOffset, animated: false)
Hope it helps someone
Reacted by Csukás Tamás, Dominik Petho, Homero Oliveira, bobson.liu, Sheji s Varkey, Ihor Pedan, Yegor, cookie, Mauro Andres Carreño, Adam Magaña and 7 more
Activity
rainypixels commentedon Jul 31, 2015
Turns out that if you change the
addRowmethod to usereloadDataas follows, the jumping issue disappears.It certainly seems like
insertRowsAtIndexPath:withRowAnimation:is the problem here because it probably attempts to adjust scrollview height immediately but by using theestimatedRowHeightof the newly inserted rows.Calling
reloadDatawhenever a couple of cells are added certainly seems like a less than ideal workaround, so I'm still interested to see if anyone has better ideas.budidino commentedon Nov 2, 2016
This stops the
tableViewfrom scrolling and therefore prevents the glitch:tableView.setContentOffset(tableView.contentOffset, animated: false)Hope it helps someone
yarodevuci commentedon Nov 7, 2018
@budidino when do you call it?
tickendy commentedon Nov 19, 2018
call "tableView.setContentOffset(tableView.contentOffset, animated: false)" just before you reloadData()
dashared commentedon Jan 29, 2019
https://brigade.engineering/reloading-uitableview-while-animating-scroll-in-ios-11-f89910c958b6 hope this will help somebody! I personally found it very useful while I stuck with the problem how to delete rows while scrolling.
appleios commentedon Dec 11, 2019
This actually helped me (see https://forums.developer.apple.com/thread/86703)