Expanding table view cells disappearing

前端 未结 7 1661
傲寒
傲寒 2021-02-12 23:52

I have cells that expand by changing their height with a setExpanded: method call.

I then call reloadRowsAtIndexPaths: to refresh the cells.

The problem is the c

7条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-13 00:20

    I had the same issue. I confirm that using no animation when reloading the row works fine.

    But it turns out the issue is caused by returning a cached UITableViewCell in cellForRowAtIndexPath when actually a fresh one is needed.

    The doc for reloadRowsAtIndexPaths:withRowAnimation: says: "Reloading a row causes the table view to ask its data source for a new cell for that row."

    Your cellForRowAtIndexPath method is returning locally cached cells. Returning a brand new cell fixed the issue in my case and no workarounds were needed...

提交回复
热议问题