6

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

Alexander Farber
  • 21,519
  • 75
  • 241
  • 416

1 Answers1

2

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
}
Mark McCorkle
  • 9,349
  • 2
  • 32
  • 42
  • Oh ok - when I set the "Content View" background color (and not for the "Table View Cell" as originally in my storyboard) - then it works both for iPad and iPhone. – Alexander Farber Apr 21 '15 at 12:08