UITableViewCell from a xibNSLayoutConstraint programmatically in
cellForRowAtIndexPathAutolayout and manual change of NSLayoutConstraint works as it should - device size, orientation etc.
BUT: on the very FIRST presentation of the cell the programmatic changes are not displayed.
Changing views and going back updates as expected.
I believe I need to put [self setNeedsUpdateConstraints] somewhere.
I tried all kinds of places (viewDidAppear, didEndDisplayingCell ...)
Where should this go?
Could it be a new cell / reused cell issue?
So, to sum things up - this is what I did in order to get nicely laid out views every time:
The UIView is now responsible for itself, no messing around in the tableviewController.
I did not need to call (void)updateConstraints anywhere which makes sense since I set up the constraints in IB and just added a property to be able to change a constant. The actual constraints were left untouched and just needed layout!
I guess, the last step makes for a little redundancy. But otherwise there were still some cells that were displaying incorrectly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With