I have a custom UITableViewCell which acts as a check list. As the user clicks on the selected item, it goes from red to green indicating a selection, however as the users scrolls further down the list, once they come back up to the top, the image has changed back to it’s default red value.
How do I go about preserving the state of an image as the tableview recycles cells?
Thanks
Sounds like you are using the
UITableViewCells to store the state of your table data. This is the wrong approach because the cells are reused. You should keep state in an separate ‘data store’. This can simply be an array you keep in memory in yourUITableViewControllersubclass or something persistent like SQLite or Core Data. This state is then transferred back to the cell when the table view asks you to intableView:cellForRowAtIndexPath:.