I have a UITableView
with approximately 20 rows. I also use the accessory checkmark to identify the selected. The problem I'm facing right now is that the selection got messed up while scrolling (here I select a few lines). Therefore, after scrolling, the selected checkmark
disappeared. Can someone help me find a way? in didSelectRowAtIndexPath:
NSMutableDictionary *rowDict = [tableList objectAtIndex:[indexPath row]]; if([tableView cellForRowAtIndexPath:indexPath].accessoryType == UITableViewCellAccessoryCheckmark) { [tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryNone; } else { [tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark; checkedIndexPath = indexPath; NSLog(@"the checked psths are :%@",checkedIndexPath); }
And in cellforrowatIndexpath
I use
if([self.checkedIndexPath isEqual:indexPath]) { cell.accessoryType = UITableViewCellAccessoryCheckmark; } else { cell.accessoryType = UITableViewCellAccessoryNone; }
But this only works for one choice. What to do for multiple choice?
source share