ios - Configuring TableView with automatic cell height results in no cells displayed -
my goal use uitableviewautomaticdimension
show cells dynamic heights in tableview. @ moment, no cells show in tableview after enabling uitableviewautomaticdimension
.
here current configuration:
- i using custom cell class, called
feedcell
feedcell
has view calledforegroundcontainerview
, has been configured such sides pinned.- i have tried pin
contentview
of cell, unable to: lastly, have following in
viewdidload
:self.tableview.rowheight = uitableviewautomaticdimension
self.tableview.estimatedrowheight = 112.0
(i deleted default function func tableview(_ tableview: uitableview, heightforrowat indexpath: indexpath) -> cgfloat
if don't use uitableviewautomaticdimension
, cells appear normally, confirming data fed tableview correctly.
what doing wrong? pointers appreciated.
i think constraints ambiguous. asking uikit automatically size cell (uitableviewautomaticdimension
), "foreground container view" not have defined height...it constrained cell (which doesn't have defined height!).
so have kind of ambiguous constraint warning in console since system doesn't know do, or it's possible "foreground container view" defaulting height of 0.0 meaning table cell height 10.5 (0.0 + constrained spacing). didn't include screenshot of shows in simulator, i'm guessing.
give "foreground container view" content or explicitly constrain it's height able see (ex. 200px). recommend give background color can see it's height on screen.
to automatic cell sizing actual cell content, should constrain views (labels, images, whatever else) inside "foreground container view" (or if want, inside cell's content view directly).
there must both top spacing , bottom spacing constraint between anticipated tallest subviews (labels, images, etc.) , container.
Comments
Post a Comment