UITableViewCell background image path
I have a UITa开发者_JS百科bleView with custom background images for the cells. I have 4 images depending on where the cell is in the table. There's one for first row, middle rows, last row, and only row. I basically followed the tutorial here: http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html
My issue occurs when a new cell is added to the table. The other cells don't update to reflect their new row positions.
When and how should I update these cells? ViewWillAppear? Or should I add it this method?
controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type
Right now the background image assignment happens in a configureCell:atIndexPath function that I'm calling in cellForRowAtIndexPath:
If there aren't that many cells, you could simply call the reloadData method on the UITableView.
However, a more efficient approach would be to use something like the reloadRowsAtIndexPaths:withRowAnimation:
UITableView method to only reload the rows you require. (You'll probably want to take a look at the NSIndexPath reference to see how it maps to tables.)
精彩评论