there is plenty of question answering the dynamic height for UITableViewCell of UITableView. However i can't solve my problem.
I have this table cell creation code:
class UINoteTabelViewCell: UITableViewCell {
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.selectionStyle = .none
}
func fill(_ note: Note) {
let view = UINote(withNote: note, atPoint: .zero)
self.contentView.addSubview(view)
}
}
This is how i create cell for table view:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "NotePreview", for: indexPath as IndexPath) as! UINoteTabelViewCell
cell.fill(notes[indexPath.row] as! Note)
return cell
}
Also table view estimatedRowHeight and rowHeight are sets to UITableViewAutomaticDimension
But table view still draws with 44.0 rows height.
I have no idea how to fix it.
PS I can't set fixed estimatedRowHeight because every cell have dynamic height
You should give the estimatedRowHeight some default value, say 60. Then the rows will have a default height of 60 but whenever the content needs height more than 60 at that time UITableViewAutomaticDimension will work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With