Roman Roman - 6 months ago 18
iOS Question

Custom UITableViewCell with Image and Label

I have some

TableView
using a basic or subtitle
UITableViewCell
and displaying an image/icon. The separator line is automatically indented and starts where the labels are displayed. So far so good. (see correct behavior)

Now I need a couple more labels and an image. Therefore, I created a custom
TableViewCell
with 4 labels. Without the image they work as expected. But when I add an image to the existing standard
ImageView
, the image is displayed, the separator line is indented but the custom labels are not. They overlay the image. (see wrong behavior)

Do I have to create a custom
ImageView
as well to get it working correctly and how is the separator line indented on that way or is there another possibility / state of the art to do something like that?

Answer

I finally ended with the solution that I created an empty Interface Builder document, added a TableViewCell, put the Label and ImageView on it, set the constraints, connected everything to the corresponding *.swift file. Finish. I hoped to reuse the ImageView from the default TableViewCell but obviously that did not work correctly (or I was too stupid).