I have a UITableViewCell
with a custom label using AutoLayout. It's constraints are set with a constant leading, trailing, bottom, and top space to the content view. The table view controller that these cells appear in is inside a UISplitViewController
. When the table view is loaded, I calculate the height of the cell using the following code:
CGSize size = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
CGFloat height = size.height;
In portrait this allows me to properly display the cell. Here is a screenshot of part of the cell:
However, when I rotate the iPad into landscape, it is not calculating the correct size and end up with too much padding:
Setting a breakpoint when the tableview:heightForRowAtIndexPath:
is called when rotated the size of the content view is not being reported properly. In fact it is reporting the old, narrower size of the table view.
How do I get my cells to resize appropriately with UISplitViewController
on iPad?