Static cell has background color on iPhone, but not on iPad - cannot find the reason

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

And for some reason, the blue background color of the top cell does not appear on the iPad:

screenshots

Please, what could be the reason for this?

I even searched with the debugger (stepped through viewDidLoad) and in the Main.storyboard XML code - and cannot find the reason.

I have reset the simulator settings, and I tried using the Yosemite and Mavericks macros.

Here is my storyboard (please click for full screen ) where I set the background color (for wAny and Hani ):

Xcode

In the preview ( full-screen mode here), the background color is present on both the iPad and iPhone:

Preview

If I did something wrong, how to find and reset it?

UPDATE:

I tried the DCGoD suggestion (thanks) - and it works. When I try to set the background color of the cells with the following code, it works (here is full screen mode ):

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 about what is happening with my storyboard. Why does it work on the iPhone, but not on the iPad? I would prefer to use a clean β€œvisual” solution (simplifies editing the storyboard).

DECISION:

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

Xcode screenshot

+6
source share
1 answer

Try changing the background for the cell and then the background for contentViews, and you will find out what is happening.

 cell.contentView.backgroundColor = YOURCOLOR 

// For a static attempt to set it in the willDisplayCell file

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

Source: https://habr.com/ru/post/985553/


All Articles