UITableViewCell reload selected image with pattern image

63 Views Asked by At

I am working with UITableViewCell. I have placed UIButton one the cell. When User clicks on the button, the commentView Appears and after added comments the button get selected image.

It is working fine but when other cells are loading in the view. The buttons on the cell also got selected Image.

I cant post Images.. :(

Please help.. Its been days, i am solving this issue but cant.

1

There are 1 best solutions below

2
On

Cells are reused, so before loading a new cell you should implement the method prepareForReuse and check it the button should be selected.

So basically, inherit from UITableViewCell, add a property (strong) BOOL addedComments; and check when prepareForReuse method is called the following:

- (void) prepareForReuse{
  // First init addedComments
  button.selected = self.addedComments;
  [super prepareForReuse];
}