I have UITableViewCell with multiple components act as rows, consist of mix elements of UILabel, UIView and UIStackView inside UIView.
Each component inside the cell has height constraint. I want the height of the cell to be dynamic by setting the constant of the height constraint zero or 21 at runtime, depend or whether it has content to show.
// more codes like below
if let mealPref = passenger.mealPref {
mealPrefHeight.constant = 21
let title = R.string.localizable.meal_request.localized()
mealPrefLabel.text = "• \(title): \(mealPref)"
} else {
mealPrefHeight.constant = 0
}
// more codes like above
It doesn't work.
I have similar problem back then, but I think it's different case. I've read this, this and this.