In my iPhone app, I am using a tableView and have added the imageView as ContentView in my tableViewcell.
At the click of button I am changing the tableView Contents. So every time I click a button it should show the corresponding image in tableViewCell.
Problem:
Suppose I am loading images 1.png, 2.png and 3.png in tableView on click of button A, B and C respectively.
Now let us consider that initially I clicked button A and 1.png appears. Now when I click the button B then 2.png appears but 1.png also remains in background. So basically it overlaps the tableViewCell with a new image.
Troubleshooting I already have done:
1) I tried releasing imageView and setting imageView.image = nil;
2) I tried reloading the table and empty out table before each button click.
3) Even I tried putting the whole code in if(cell==nil) clause of cellForRowAtIndexPath
method
I have got the answer and I am really thankful to Ben Gottlieb: