I am developing an application which has a UITableView with custom UITableViewCells. The cells contain checkboxes and 3 labels. The user can select multiple rows by clicking on the checkboxes. When I select more than one row and scroll the table view, the checkmark vanishes from the checkbox. This means the selected rows are changed to unselected mode. How this can be fixed?
I am developing an application which has a UITableView with custom UITableViewCells . The
Share
I think your problem may be with cell reuse. Create an
NSMutableDictionaryin your controller (should be and instance variable), and create it like so:Do this for all your rows, or if needed, calculate the rows and their indexes, but set all their objects to
[NSNumber numberWithBool:NO.Now, in
tableView:didSelectRowAtIndexPath:Now that we have a way of storing whether a cell is selected or not, change your cell identifier to work for your cells:
Now, update your custom cell class to accept
@"0"and@"1"as identifiers, and update their selected state automatically based on this input.