1

如何取消选择 tableView 中先前选择的行?我找不到获取 oldIndexPath 的解决方案

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
    if (newCell.accessoryType == UITableViewCellAccessoryNone) {
        newCell.accessoryType = UITableViewCellAccessoryCheckmark;
    }  
}
4

1 回答 1

2

除非您存储以前的索引路径,否则您将无法检索它。
只需将其存储在 ivar 中,当您检测到选择了一行时,下次您将能够删除前一个单元格上的复选标记。

于 2011-07-23T13:05:49.297 回答