didSelectRowAtIndexPath:如何让旧的indexPath取消选中复选标记?

时间:2011-07-22 18:07:47

标签: objective-c ios uitableview nsindexpath

如何在tableView中取消选择以前选择的行?我找不到获取oldIndexPath

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

1 个答案:

答案 0 :(得分:2)

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