Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableViewCell with Checkmark not visible

I've a problem with my UITableView inside PopoverController. When I touch cell, the didSelectRowAtIndexPath function is called, and the cell accessoryType is changed. Example simplified :

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [self.listItems objectAtIndex:indexPath.row];
    cell.accessoryType = UITableViewCellAccessoryCheckmark;
    [self.tableView reloadData];
    [self.popoverController dismissPopoverAnimated:YES];
}

It's working, the cell are checked, but it's not visible on my tableview : I can't see the blue checkmark. However, in touch state on the cell, the checkmark is visible in white (and the cell background is gray). But not visible in default state.

Do you have any idea why my checkmark are not visible in default state ?

Thanks,

Edit: Add screenshot, for a cell with accessoryType = UITableViewCellAccessoryCheckmark

enter image description here

like image 332
alexmngn Avatar asked Jun 06 '12 08:06

alexmngn


2 Answers

I've tried the answer Jacky Boy - didn't help. But something was there in the deselection...

So I've tried to deselect the cell in the didSelectRowAtIndexPath: before adding the checkmark accessory:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

   [tableView deselectRowAtIndexPath:indexPath animated:YES];
   UITableViewCell* selectedCell = [tableView cellForRowAtIndexPath:indexPath];

   if (row != _selectedRow) {

       if (selectedCell.accessoryType == UITableViewCellAccessoryNone) {

          selectedCell.accessoryType = UITableViewCellAccessoryCheckmark;
          _selectedRow = row;

       } else if (selectedCell.accessoryType == UITableViewCellAccessoryCheckmark) {

          selectedCell.accessoryType = UITableViewCellAccessoryNone;
       }
       [tableView reloadData];
   }

}

And for me it worked at last - the nice dark checkmark now is clearly visible on the cell!

Of course there is a part in cellForRowAtIndexPath: similar to described in arexx's answer.

like image 21
AndreyMan Avatar answered Oct 20 '22 17:10

AndreyMan


This happened to me when I changed the global tint color to white. Once I realized, I went into the UITableView and change the tint color locally for just this table. Fixed.

like image 55
Iron Mike Avatar answered Oct 20 '22 18:10

Iron Mike