iOS Way the Checkmark disappears when begin scroll down

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

Way the Checkmark disappears when begin scroll down.

Heres the code for the didSelectRowAtIndexPath method:

- (void)tableView:(UITableView *         


        
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    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]];
           }
    }
    

提交回复
热议问题