I have a problem with an UITableViewCell that has UIImageView and a UILabel. All constraints are set programmatically, so that the constraints are adjusted so that the height of the cell varies dynamically with the height of the UILabel plus a certain padding, while the UIImageView must adapt to the height of the UITableViewCell. However, when I place the image, the height of the cell increases until it is that of the Image.
contentView.addSubview(coverView)
contentView.addSubview(indexUnitLabel)
NSLayoutConstraint.activate([
coverView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
coverView.topAnchor.constraint(equalTo: contentView.topAnchor),
coverView.bottomAnchor.constraint(equalTo: contentView.leadingAnchor),
coverView.widthAnchor.constraint(equalToConstant: 68),
titleLabel.topAnchor.constraint(equalTo: contentView.topAnchor, constant: padding),
titleLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -padding),
titleLabel.leadingAnchor.constraint(equalTo: coverView.trailingAnchor, constant: padding),
titleLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -padding)
])
Is there any way to set the constraints so that the height of the UIImageView adapts to the height of the cell dynamically?