0

I was trying to design a custom cell for UItableView, but for some unknown reasons the constraints that I set for the elements inside were ignored. In fact, I don't even know why the elements were arranged in the ways they did.

It looks like this in IB:

It looks like this in IB

Details:

Details

But somehow it appears like this:

But somehow it appears like this.

Tom
  • 15,514
  • 17
  • 42
  • 51

1 Answers1

2

You should either

X) Turn on auto height for TableView

enter image description here

Y) Or, implement this delegate method

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    return UITableView.automaticDimension
}

func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
    return UITableView.automaticDimension
}
Thilina Chamath Hewagama
  • 8,881
  • 3
  • 31
  • 43