Way the Checkmark disappears when begin scroll down.
Heres the code for the didSelectRowAtIndexPath
method:
- (void)tableView:(UITableView *
Try this one to store checkmark cell data.And hope this solves your problem:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
if ([selectedCell accessoryType] == UITableViewCellAccessoryNone || [selectedCell accessoryType]== UITableViewCellAccessoryDisclosureIndicator)
{
[selectedCell setAccessoryType:UITableViewCellAccessoryCheckmark];
[Mybuffer addObject:[arrItem objectAtIndex:indexPath.row]];
}
else
{
[selectedCell setAccessoryType:UITableViewCellAccessoryNone];
[Mybuffer removeObject:[NSNumber numberWithInt:indexPath.row]];
}
}
Make sure to store the checkmark in your model somewhere. Cells are recreated on the fly as the user scrolls the UITableView
. Then make sure to re-set the checkmark correctly in tableView:cellForRowAtIndexPath:
.