我有一个约有20行的UITableView
。我也使用复选标记附件来标识所选内容。我现在面临的问题是,当我滚动时(这里我选择了多行),选择会变得混乱。所以滚动后所选的checkmark
已经消失。任何人都可以帮我找到一种方法吗?在didSelectRowAtIndexPath:
如何跟踪UITableView中所有选定单元格的索引
NSMutableDictionary *rowDict = [tableList objectAtIndex:[indexPath row]];
if([tableView cellForRowAtIndexPath:indexPath].accessoryType == UITableViewCellAccessoryCheckmark)
{
[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryNone;
}
else
{
[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;
checkedIndexPath = indexPath;
NSLog(@"the checked psths are :%@",checkedIndexPath);
}
而在cellforrowatIndexpath
我用
if([self.checkedIndexPath isEqual:indexPath])
{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
else
{
cell.accessoryType = UITableViewCellAccessoryNone;
}
但这仅适用于单一选择。我应该怎么做多选?
所以你说要怎么做didSelectRowAtIndexPath方法,然后在的cellForRowAtIndexPath数组或取消选中创建单元正确匹配吗? – rashii
是的,你说得对 – Ilanchezhian