Ios – Why doesn’t UITableViewCell background color work (set in interface builder)

cocoa-touchiosuikituitableview

Why doesn't UITableViewCell background color work (set in interface builder)?

I note from some searching that the follow code set in your custom subclass of UITableViewController does work (see below):

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    cell.backgroundColor = [UIColor redColor];
}

But I would still like to just understand why interface builder has a background color setting for the TableViewCell, which effectively doesn't seem to work?

Best Answer

It's a bit late, but I just ran into this issue... Setting the background color on the contentView works fine:

cell.contentView.backgroundColor = [UIColor redColor];
Related Topic