iOS Way the Checkmark disappears when begin scroll down

后端 未结 2 510
轮回少年
轮回少年 2021-01-23 09:25

Way the Checkmark disappears when begin scroll down.

Heres the code for the didSelectRowAtIndexPath method:

- (void)tableView:(UITableView *         


        
相关标签:
2条回答
  • 2021-01-23 10:10

    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]];
           }
    }
    
    0 讨论(0)
  • 2021-01-23 10:23

    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:.

    0 讨论(0)
提交回复
热议问题