我制作了一个 tableView,我需要在其中选择多个选项。选项被选中,但是当我滚动表格视图时,复选标记选项消失,其他一些行显示该复选标记。这是我在didselectedrowAtindex
方法中的代码table_option
是UITableView
并且selectedcells
是NSMutableArray
[table_option deselectRowAtIndexPath:indexPath animated:YES];
NSNumber *rowNsNum = [NSNumber numberWithUnsignedInt:indexPath.row];
if ( [selectedCells containsObject:rowNsNum] )
{
if (cell.accessoryType == UITableViewCellAccessoryCheckmark)
cell.accessoryType = UITableViewCellAccessoryNone;
else
cell.accessoryType = UITableViewCellAccessoryCheckmark;
[selectedCells removeObject:rowNsNum];
sel.text=@"Select";
// cell.accessoryType = UITableViewCellAccessoryNone;
}
else
{
if (cell.accessoryType == UITableViewCellAccessoryCheckmark)
cell.accessoryType = UITableViewCellAccessoryNone;
else
cell.accessoryType = UITableViewCellAccessoryCheckmark;
[selectedCells addObject:rowNsNum];
sel.text=@"Selected";
// cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
[table_option reloadData];
请尽快帮助