How to solve the problem that UITableView uses reloadRowsAtIndexPaths to cause ghosting in animation?

I used a UITableView, in the project. This UITableView has three cell. There is a need to refresh the first cell, which will change the height of the cell. While changing the height of the first cell, the second and third cell will move, and this movement needs to be animated. I used reloadRowsAtIndexPaths to implement this requirement, but found that in the process of animation, the third cell will have ghosting. At the end of the animation, the ghosting disappears.

The

code is as follows. BeginUpdates, endUpdates:
[self beginUpdates];
[self reloadRowsAtIndexPaths.]; / / only the first cell
[self endUpdates];

is used here.

through debug, it is found that cellForRowAtIndexPath: will enter twice. The first time is to brush the first cell, and the second time is to brush the third cell.
this is the reason for animation ghosting. I didn"t explicitly swipe the third cell with reloadRowsAtIndexPaths.

The

question arises: when reloadRowsAtIndexPaths, the system will not only brush what it should brush, but also brush some other cell that has not been explicitly brushed? And how should we solve this ghosting problem?

Feb.27,2021

Don't write the first cell in cell, write it in tableView.tableHeaderView, if it has a high gradient effect. Direct reloadData should work.

Menu