Я передаю представление в UITableViewCell из метода cellForForAtIndex.Я хочу изменить размер ячейки в зависимости от содержимого UIView, но высота ячейки не меняется.Я пытался добавить ограничение от кодирования, когда я добавляю пользовательский вид.Метод UITableViewCell:
func addContainerView(view:UIView){
vwContainer.addSubview(view)
view.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint(item: view, attribute: .leading, relatedBy: .equal, toItem: vwContainer, attribute: .leading, multiplier: 1.0, constant: 0.0).isActive = true
NSLayoutConstraint(item: view, attribute: .trailing, relatedBy: .equal, toItem: vwContainer, attribute: .trailing, multiplier: 1.0, constant: 0.0).isActive = true
NSLayoutConstraint(item: view, attribute: .top, relatedBy: .equal, toItem: vwContainer, attribute: .top, multiplier: 1.0, constant: 0.0).isActive = true
NSLayoutConstraint(item: view, attribute: .bottom, relatedBy: .equal, toItem: vwContainer, attribute: .bottom, multiplier: 1.0, constant: 0.0).isActive = true
}
Вышеупомянутый код вызывается из следующего кода в CellForRowAtIndex:
if let rowObj = objData?.itemsArray?[indexPath.row] as? TableViewDataFormat, let cell = tableView.dequeueReusableCell(withIdentifier: TableViewCell, for: indexPath) as? HiltiTableViewCell {
if let container = rowObj.containerview{
cell.addContainerView(view: container)
cell.lblTitle.text = rowObj.cellTitle
}
return cell
}
Целью здесь является создание настраиваемого представления uitable в пользовательской среде, где я могу передатьРазмер UIView и ячейки должен изменяться в зависимости от содержимого передаваемого представления.
Edit 1: Попытка добавить содержимое поверх viewview выглядит следующим образом: cell.contentView.addSubview (container), но все еще получаетвид перекрытия выглядит следующим образом: ![enter image description here](https://i.stack.imgur.com/BMxFU.png)
В нем должно быть 3 разные ячейки: первая с изображением uiview и две с изображением внутри