Open reenaphilip opened 4 years ago
For all cell related set up you should use cellSetup
or cellUpdate
. However that might not fix this issue. LabelRow should work just like any UITableViewCell. It uses the same textLabel. Have you been able to accomplish that on a normal UITableViewCell?
I have added below code
cellUpdate({ (cell, row) in
cell.detailTextLabel?.numberOfLines = 0
cell.detailTextLabel!.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
cell.detailTextLabel!.leftAnchor.constraint(equalTo: (cell.textLabel?.rightAnchor)!, constant: 15),
cell.detailTextLabel!.rightAnchor.constraint(equalTo: cell.contentView.rightAnchor, constant: -15),
cell.detailTextLabel!.bottomAnchor.constraint(equalTo: cell.contentView.bottomAnchor, constant: -15),
cell.detailTextLabel!.topAnchor.constraint(equalTo: cell.contentView.topAnchor, constant: 15)
])
cell.updateConstraintsIfNeeded()
})
When the form is created, the this doesn't work. But in the form there is another accordion section. Once I collapse that section automatically the label constraints works. But this label is not in that section. But I need to work it when I create the form.
Attached a video
You are adding a new set of constraints on each update pass. Have you tried adding those constraints and setting all of that only in cellSetup
? Also try setting cell.setNeedsLayout()
after adding the constraints. If you do this in cellSetup, then I think you should not need to call updateConstraintsIfNeeded
How to make LabelRow multiline with dynamic height based on the value
I tried setting the number of lines to zero.
But its not working. How can I achieve it ?