UITableView scrolls to top when reloading cells with changing cell heights

后端 未结 4 916
面向向阳花
面向向阳花 2020-12-09 05:57

I have a table view which contains a placeholders while it loads in images. When the image is loaded, I call reloadRowsAtIndexPaths:withRowAnimation:. At this p

4条回答
  •  一整个雨季
    2020-12-09 06:32

    It's an issue with the estimatedRowHeight.

    The more the estimatedRowHeight differs from the actual height, the more the table may jump when it is reloaded, especially the further down it has been scrolled. This is because the table's estimated size radically differs from its actual size, forcing the table to adjust its content size and offset.

    The easiest workaround is to use a really accurate estimate. If the height per row varies greatly, determine the median height for a row, and use that as the estimate.

提交回复
热议问题