6
votes

In an iOS 8 project with storyboard and adaptive layout (aka size classes) I use static cells in 2 scenes -

And for some reason the blueish background color of the top cell is not shown on iPad:

screenshots

Please, what could be the reason for that?

I've even searched with debugger (stepped through viewDidLoad) and in XML-code of Main.storyboard - and can not find the cause.

I have reset the simulator settings too and have tried on Yosemite and Mavericks macs that I have.

Here is my storyboard (please click for fullscreen) where I set the background color (for wAny and hAny):

Xcode

In the preview (here fullscreen) the background color is present in both iPad and iPhone:

Preview

If I have done anything wrong here, how to find and reset this?

UPDATE:

I've tried DCGoD's suggestion (thanks) - and it works. When I try setting the cells background color with the following code it works (here fullscreen):

screenshots

#define THEME_COLOR_BLUE [UIColor colorWithRed:19.0/255 green:175.0/255 blue:207.0/255 alpha:1.0]

- (void)tableView:(UITableView *)tableView
    willDisplayCell:(UITableViewCell *)cell
    forRowAtIndexPath:(NSIndexPath *)indexPath
{
    cell.contentView.backgroundColor = THEME_COLOR_BLUE;
}

And I understand, that I could use this as a workaround...

But I'm still curious what is going wrong with my storyboard. Why does it work for iPhone, but not iPad? I'd prefer to use a pure "visual" solution (makes the storyboard easier to edit).

SOLUTION:

For some strange reason the fix is to set the background color of the "Content View" (and not for its parent - the "Table View Cell". Here fullscreen):

Xcode screenshot

1
were you also able to set the separator color?jasonaibrahim
I am not sure, sorryAlexander Farber

1 Answers

2
votes

Try changing the background for the cell and then it's contentViews background and you'll discover what's happening.

cell.contentView.backgroundColor = YOURCOLOR

// For static try setting it in willDisplayCell

func tableView(tableView: UITableView!, willDisplayCell cell: UITableViewCell!, forRowAtIndexPath indexPath: NSIndexPath!) {
    cell.contentView.backgroundColor = YOURCOLOR
}