Вы можете попробовать одну вещь -> изменить приоритет ограничения высоты просмотра таблицы на 100 и попытаться удалить всю фиксированную высоту ячейки. Надеюсь, это поможет вам.
Попробуйте это. Это прекрасно для меня.
let cellHeight = 100.0
var cell : tableCell?
let detailArr : [UIColor] = [.red,.yellow,.black,.blue]
override func viewWillAppear(_ animated: Bool) {
self.changeTableHeight()
}
func changeTableHeight()
{
let animator = UIViewPropertyAnimator(duration: 0.5, timingParameters: UICubicTimingParameters(animationCurve: .linear))
animator.addAnimations {
self.view.layoutIfNeeded()
}
tableviewHeight.constant = CGFloat(Double(detailArr.count) * self.cellHeight)
self.view.setNeedsLayout()
animator.startAnimation()
self.tableview.reloadData()
}
![Cell image with constraint](https://i.stack.imgur.com/yNbIX.png)
![Table view with fix height](https://i.stack.imgur.com/kEYe8.png)
![Table with orange background color and height as per total number of cell](https://i.stack.imgur.com/5b3Gp.png)