我有一个如下图所示的表格视图:
当我在缺席部分选择表格行时,我想更改复选框并使用标记复选框
我知道我应该使用这个方法 didSelectRowAtIndexPath: "that when user select the row it should change the picture" 但我不知道如何
你能帮帮我吗
提前致谢!
这是我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *key = [[self sectionKeys] objectAtIndex:[indexPath section]];
NSArray *contents = [[self sectionContents] objectForKey:key];
NSString *contentForThisRow = [contents objectAtIndex:[indexPath row]];
if (indexPath.section != 2) {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
cell.textLabel.text =contentForThisRow;
return cell;
}
else {
CheckBoxCompensationViewCell *cell = (CheckBoxCompensationViewCell*)[tableView
dequeueReusableCellWithIdentifier:@"CheckBoxCompensationViewCell"];
cell.imageView.image=[UIImage imageNamed:@"emptycheck-box.png"];
cell.checkBox.image = image;
if(indexPath.row == 0){
cell.compensationText.text =@"Red";
}
else if (indexPath.row == 1){
cell.compensationText.text =@"Green";
}else if(indexPath.row == 2){
cell.compensationText.text =@"Blue";
}
return cell;
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// I don't know what should I have here , probably mark box image but I don't know how
}