Word wrapping in a custom table cell

Needed to display some text of various lengths in a table cell.

If I used a label, text that would fit on one line appeared in the middle (looked silly).

I tried use a texture. That worked as far as the display of the text went, but the text area captured the tap (not the row) so the selectionChanged event didn’t fire.

Then I made the textarea both readonly and not enabled. Text displays as expected and the table also works.

The final problem is that the text area’s background is opaque so one does not see the gray when the row is selected. I backed all the controls in the cell with a white rectangle (I’m using a check mark to indicate the selected cell).

Hope this helps someone.

The way to do this is to create a dynamic custom cell which contains a label With wrapping turned on. The cell will automatically increase its height as needed by the label. Just make sure you add constraints to the label so that the top & bottom have a little buffer space.

1 Like