My tableviewcell height stays fixed even though I do the following:
tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = 150
I have one imageview and one label inside the cell and I gave constraints to each side.
Also, I tried:
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
I need a fixed height for my cell. It doesnt need to be dynamic. But no matter what i tried the height stays around 50px.
Any help?
2
Answers
you can set the height you want with heightForRowAtIndexPath, hopefully that helps
Setting
automaticDimension
is based on using auto layout in your cells.This means you must add a
NSLayoutConstraint
to all sides of aUILabel
(or any other control you use in your cells) and theUITableViewCell
container in interface designer or in code. In case of a label, configure setting ‘Lines’ to 0 and ‘Line Break’ to Word Wrap.