UITableview accessory type disappear while scrolling

前端 未结 3 1561
情书的邮戳
情书的邮戳 2021-01-13 11:26

I have made a tableView in which i need to select multiple options. The options are selected but when i scroll the table view the check mark option get disappear and some ot

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-13 12:10

    In my case just setting accessoryType = UITableViewCellAccessoryCheckmark in cellForRowAtIndexPath didn't work.

    The problem occurs when the UITableView reaches its first element and if you try to scroll more, the visible cells go down and their checkmarks gets gone.

    NSNumber *rowNsNum = [NSNumber numberWithUnsignedInt:indexPath.row];
    
    [cell setAccessoryType:UITableViewCellAccessoryNone];// tricky part is this line
    
    if ( [selectedCells containsObject:rowNsNum]  )
    {
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
    }
    else
    {
        cell.accessoryType = UITableViewCellAccessoryNone;
    }
    

提交回复
热议问题