[ios] UITableVIew单选效果

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   
    int newRow=[indexPath row];
    int oldRow;
    if(self.lastPath==nil)
    {
        oldRow=-1;
    }else {
        oldRow=[self.lastPath row];
    }
    if(newRow!=oldRow)
    {
        [tableView cellForRowAtIndexPath:indexPath].accessoryType=UITableViewCellAccessoryCheckmark;
        [tableView cellForRowAtIndexPath:self.lastPath].accessoryType=UITableViewCellAccessoryNone;
        
        self.lastPath=[indexPath copy];
    }

}

原文地址:https://www.cnblogs.com/jinjiantong/p/2974998.html