I’ve got a custom UITableViewCell subview that has a button on it which has a background color representing a priority. The user is allowed to drag the cells around in the table, which changes the priority of the object represented by that row. I want to update the color of the button when they’re done, so I’ve implemented this:
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
//update data source
theCell.button.backgroundColor = newColor;
}
This works insofar as the background color of the button changes as soon as I let up on the move control. However, once the cell animates into place, the background color changes back to its previous color. Other values on the cell are changed properly (if, for example, I change the text, it stays changed).
Any thoughts on what’s wrong or a workaround?
As far as I know it’s not wise to change anything in the row while any animations are taking place. (I tried finding this in Google but failed to find an official reference).
I’ve got around this by doing something like:
I found that this allows the animation to finish and it doesn’t throw away the changes to the cell.