Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

moveRowAtIndexPath doesn't refresh the cell's content

iOS 5 finally added a moveRowAtIndexPath:toIndexPath: method to UITableView. Problem is, calling it only moves the row, it doesn't update/redraws it. The only way to do so seems to be by finding the cell and calling setNeedsDisplay directly. But this is tricky since you never know whether the cell already got moved or not.

I can't call reloadRowsAtIndexPaths: either, since I'm not allowed to have 2 animations applied to a single row inside the same beginUpdates-endUpdates block.

There are may workarounds I can think of, like splitting the whole thing into 2 animation blocks. But I'm wondering whether I'm missing something, as the whole behavior seems odd to me.

like image 400
samvermette Avatar asked Oct 22 '11 18:10

samvermette


1 Answers

Finally received an official answer from Apple regarding this issue:

Engineering has determined that this issue behaves as intended based on the following information:

Only insert and update cause the cell to be requested from the data source (the first because it's new and the second because you've explicitly told the table view to update the cell). Delete and move don't update the contents because that's not implicit in the action being performed. If you need to change the contents of the cell during the update, just reach into the cell and change the contents.

like image 92
samvermette Avatar answered Sep 22 '22 06:09

samvermette