How to change the height of a prototype cell in Xcode for tableView?
You can change the height of a cell by adding Constraints to your label inside the cell or otherwise by adding this to your viewDidLoad
:
tableView.rowHeight = 40
Or you may add the following delegate function to change the height:
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 40
}
For those who come here just wanting to change the row height during design time, you can select the Table View Cell and then set the row height in the Size inspector.
I'm adding this answer because I found this question when I was having trouble manually dragging the cell height to something else. As the OP noted, though, this will not change the cell height at run time. The cell is auto-sized depending on its content. If you need to give it a fixed height, see the accepted answer.
You can use tableView delegate method and specify the value for your heightForRowAt
say you want it to be 80:
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return CGFloat(80)
}