I\'m working on a project. I have plenty of UITableView
s which are set as clear color. Their views\' background color are set to my custom color and everything
I just had this issue and fixed it by changing the backgroundColor of the View (as opposed to the one of the tableView). Seems on iPad, that's the one that is used first and in my case it was set to white.
Building off of Ben Flynn's answer... cell.contentView background color is not necessarily equal to the cell.background color. In which case, I found that this worked in resolving the iPad white background issue in more situations:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
...
cell.backgroundColor = cell.backgroundColor;
return cell;
}
While the statement looks ridiculous and crazy... it resolves the issue.
I'm using Storyboard
with UITableViewControlrs
, so the most simple decision was to subclass all controllers, and add this method to parent
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
cell.backgroundColor = [UIColor clearColor];
}
}
Instead of setting the background color, trying using a background view instead, like this:
- (void)viewDidLoad {
self.tableView.backgroundView = [UIView new];
self.tableView.backgroundView.backgroundColor = [UIColor clearColor];
}
I've had problems where using the backgroundColor doesn't always produce an effect, but setting a background view instead works fine.