UPDATE
I know what is causing this strange breaking of layout. It is the setting of an Accessory (UITableViewCellAccessory). If I stop specifying an accessory the layout does not break. I have not added this as the answer because an answer would need a solution that gives me an accessory without breaking layout
Most of the issues I see people having with custom cells of dynamic height are that they do not have the correct height until they are rotated. However I see the opposite: All cells are the height valid for their dynamic content. Scrolling up and down does not break this. However if I scroll to the bottom of the list, then rotate the device, then rotate back one row will become between 0.5 and 1.5 times the height of the screen.
A further rotation or a further scroll will put the rows back to the expect height. I have included a couple of before and after screenshots
The UITableView is defines as follows
this.rootChildrenTable = new UITableView()
{
TranslatesAutoresizingMaskIntoConstraints = false,
AccessibilityIdentifier = "rootChildrenTable",
RowHeight = UITableView.AutomaticDimension,
EstimatedRowHeight = 44.0f,
BackgroundColor = UIColor.GroupTableViewBackgroundColor,
TableFooterView = new UIView(),
TableHeaderView = this.searchBar,
KeyboardDismissMode = UIScrollViewKeyboardDismissMode.OnDrag
};
Note the usual suspects are set RowHeight
and EstimatedRowHeight
. As soon as I remove the Lines = 0
from the label, making the rows all the same height, the issue goes away.
Any idea what else I should be looking at?
beginUpdate
andendUpdate
to update the cell height – PidginUITableViewController
or aUITableView
inside aUIViewController
? – Amenable