下の図のようなテーブル ビューがあります。
セクション不在で表の行を選択するときに、チェック ボックスを変更し、マーク チェック ボックスを使用したい
私はこのメソッドを使用する必要があることを知っています didSelectRowAtIndexPath: 「ユーザーが行を選択すると、画像が変更されるはずです」
助けてくれませんか
前もって感謝します!
ここに私のコードがあります:
- (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
}