My problem is similar to this and that SO question. Now the content view has no height problem anymore because I added an auto resizing mask (flexible height/width) to the content view in updateConstraints
of my custom table view cell for iOS 7.
But the height of the cell still has the same problem. It gets a height of 44 points from the auto resizing mask.
Unable to simultaneously satisfy constraints
// ...
"<NSAutoresizingMaskLayoutConstraint:0x7a4f61f0 h=-&- v=--&
V:[TestCellAuto_CustomCell:0x7a43bb10(44)]>"
The layout is completely destroyed and in the output I get the above error. On iOS 8.1 everything is working fine. Only iOS 7 makes this problems.
How can I tell iOS that it should calculate the correct cell height?
Seems that you have to set rowHeight
or implement heightForRowAtIndexPath
as described in Using Auto Layout in UITableView for dynamic cell layouts & variable row heights.
The height of my cells is always the same, but I don't know why auto layout can't calculate the row height correctly on iOS 7. On iOS 8 the height of the row is wrong after rotation and the layout is messed up. Only if I call reloadData
in willRotateToInterfaceOrientation:duration:
solves the problem. But for iOS 7 I still have to set the height. Not an ideal solution.
To sum up, this is what I've to do now:
iOS 7:
self.contentView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
before adding constraints and- define a fixed
rowHeight
The first is for the contentView
and the second for the UITableViewCell
.
iOS 8:
- I can either set a fixed
rowHeight
or - use
reloadData
inwillRotateToInterfaceOrientation:duration:
What is wrong with auto layout? Am I doing something wrong? Are you always setting a fixed height?