Based on this SO post I updated my TableViewControllers to always call layoutIfNeeded after populating my custom tableviewcells. In fact this is the only way to have the cells render correctly with multiple multiline labels.
The cells now render correct but my console is flooded with broken constraint messages which I can't figure to fix.
For example:
(
"<NSLayoutConstraint:0x167c1f20 UILabel:0x166bf820'Intendant des Wolfgang Bo...'.leading == UITableViewCellContentView:0x167b6de0.leadingMargin>",
"<NSLayoutConstraint:0x167c44b0 UILabel:0x166bf820'Intendant des Wolfgang Bo...'.trailing == UITableViewCellContentView:0x167b6de0.trailingMargin>",
"<NSLayoutConstraint:0x167c0af0 'UIView-Encapsulated-Layout-Width' H:[UITableViewCellContentView:0x167b6de0(0)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x167c44b0 UILabel:0x166bf820'Intendant des Wolfgang
Bo...'.trailing == UITableViewCellContentView:0x167b6de0.trailingMargin>
One of the troublesome cells looks as simple as this:
The constraints and also hugging priority / compression resistance seemed to be set properly:
I tried everything from implementing init:coder/awakeFromNib/layoutSubviews, etc. in my CustomCell and set the autoresizing to
UIViewAutoresizing.FlexibleWidth and UIViewAutoresizing.FlexibleHeight
also setting the contentView.frame = self.bounds
as described in several posts on SO, such as this one but nothing seems to work. Also playing around with >= constraints on the "broken" ones doesn't help.
This is another example in case it helps someone to find a quick solution:
(
"<NSLayoutConstraint:0x1624f800 H:[UILabel:0x16143b60'27. April 2015 \U00b7 spiegell...']-(8)-| (Names: '|':UITableViewCellContentView:0x1616f1b0 )>",
"<NSLayoutConstraint:0x14f022e0 H:|-(8)-[UILabel:0x16143b60'27. April 2015 \U00b7 spiegell...'] (Names: '|':UITableViewCellContentView:0x1616f1b0 )>",
"<NSLayoutConstraint:0x14d95bf0 'UIView-Encapsulated-Layout-Width' H:[UITableViewCellContentView:0x1616f1b0(0)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x1624f800 H:[UILabel:0x16143b60'27. April 2015 · spiegell...']-(8)-| (Names: '|':UITableViewCellContentView:0x1616f1b0 )>
Honestly, what's wrong?