Ios 检查表视图单元格上的登录
当我使用此选项对所选单元格进行复选标记时,我的表视图中有100个单元格Ios 检查表视图单元格上的登录,ios,uitableview,Ios,Uitableview,当我使用此选项对所选单元格进行复选标记时,我的表视图中有100个单元格 [tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark; 它在其他单元格上也会自动显示,我不明白为什么会发生这种情况。如果重复使用表格视图单元格,则必须确保不仅在特定单元格上设置了复选标记,而且在其他单元格上也未设置复选标记 比如说 if (somethingHappens) { [ta
[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;
它在其他单元格上也会自动显示,我不明白为什么会发生这种情况。如果重复使用表格视图单元格,则必须确保不仅在特定单元格上设置了复选标记,而且在其他单元格上也未设置复选标记 比如说
if (somethingHappens) {
[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;
} else {
[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryNone;
}
始终在显示前清除单元格,而不是检查条件。试试这个:
[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryNone;
if (shouldCheckMark) {
[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;
}