UITableView Cell background color not changing?

I have a UITableView created in two storyboards - one for the iPhone and one for the iPad.

I set it up in the iPhone storyboard in such a way that the cells have a clear background and so the background image shows - it works great.

HOWEVER, when I copy this view into an iPad storyboard, for some reason the table cells have a white background even though all the settings are the same (a clear color still set in the builder).

What could be causing this?

EDIT - I looked at this further, and if I changed the color of the line to anything it doesn't change - it stays white for some reason: /

+3


source to share


3 answers


There is a known issue with this and the fix is ​​to add the following to the .m file for your class:



   - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    [cell setBackgroundColor:[UIColor clearColor]];
}

      

+1


source


You have to set the backgroundColor of the cellView content to your color



cell.contentView.backgroundColor = [UIColor yourcolor];

      

+1


source


From iOS 7, UITableViewCell has a white background by default.

Install: cell.contentView.backgroundColor = [UIColor clearColor];

and ultimately:cell.contentView.backgroundView = nil;

And confirm yours as well: tableview.backgroundColor = [UIColor clearColor]; tableview.backgroundView = nil;

0


source







All Articles