2

How can I make the cells transparent. I only want to show the selected cells with a checkmark which I have done:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)path {
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:path];

    if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {
        cell.accessoryType = UITableViewCellAccessoryNone;
    } 
    else {
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
    }
}

and when I first create the cells I do that next line of code to get rid of the blue background

cell.selectionStyle = UITableViewCellSelectionStyleNone;

but I have a weird issue where it takes 2 clicks to add and remove the checkboxes. Maybe this is not the right way to do it?

Pittfall
  • 2,751
  • 6
  • 32
  • 61

1 Answers1

1

You can read about making transparent UITableViewCells here: How to create a UITableViewCell with a transparent background

And as to your second issue, it appears that this is perhaps what you actually want:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)path {
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:path];
    cell.accessoryType = UITableViewCellAccessoryCheckmark;
}

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)path {
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:path];
    cell.accessoryType = UITableViewCellAccessoryNone;
}
Community
  • 1
  • 1
Seamus Campbell
  • 17,816
  • 3
  • 52
  • 60
  • The transparent background code that I added was good but the second part of what you showed me was what I needed – Pittfall Apr 10 '13 at 18:01