当前位置: 动力学知识库 > 问答 > 编程问答 >

objective c - ios 4.3 UITableView/UITableViewCell w/ custom background not redrawing on delete

问题描述:

I have a UITableView that uses custom background images for cells (rounded edges for the first & last cell). When the first or last cell is deleted (via commitEditingStyleForRowAtIndexPath), the tableView doesn't immediately redraw the cells. That is, if I delete the first cell (with the rounded edges), the second cell becomes the first cell (as expected), but it doesn't have the rounded edges background image. It is not until this cell is dragged out of the view, or I switch to a different tab & back, that the "new" first cell has the appropriate background image. Now, I can make a call to reloadData after the delete operation and this forces the whole table to redraw, which seems to work, but the API docs advise against doing this & it seems inefficient. So, my question is, where in the call stack is the best place to trigger a redraw of my "new" first cell after a commitEditingStyleForRowAtIndexPath operation?

Thank you

网友答案:

Reload only that row/cell:

  - (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths 
             withRowAnimation:(UITableViewRowAnimation)animation

and give it an indexPath row of 0 or (last) depending on which one it was.

分享给朋友:
您可能感兴趣的文章:
随机阅读: