0

I moved my code out of my ViewController into a UIView subclass. The view hierarchy stayed the same (literally all I did was move the code from ViewController to the subclass and reconnect the TableView to the subclass in the storyboard).

Now the background colors of my UITableViewCells are not showing. I am doing this:

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
if ([tableView isEqual:self.prizeTable]) {
if (indexPath.section == 0) {
  if (indexPath.row % 2 == 0) {
    [cell setBackgroundColor:[LCAppDelegate colorFromHexString:PayoutTableRow2BGColor]];
  } else {
    [cell setBackgroundColor:[LCAppDelegate colorFromHexString:PayoutTableRow1BGColor]];
  }
}
}
}

This code IS getting called, but, somehow by the time that cellForRowAtIndexPath gets called the color is null. Even setting the color again inside cellForRowAtIndexPath doesn't work.

The bizarre thing is that if I scroll the table, then the colors appear on the hidden then exposed rows.

4

0 回答 0