1

I need to change row height in cellForRowAtIndexPath, using UITableView.

heightForRowAtIndexPath executes before cellForRowAtIndexPath, but in cellForRowAtIndexPath I'm settings content to rows, depended on which height must be recalculated.

Hreno Hrenovich
  • 336
  • 6
  • 16

2 Answers2

10

You can't, the only place you can and should change is heightForRowAtIndexPath But there are other solutions for you problem, that are explained very well here

I encourage you to check third solution whitch enable Row Height Estimation.

Community
  • 1
  • 1
Andrew
  • 885
  • 1
  • 10
  • 15
0

You can set the height in the viewDidLoad for all cells

self.tableView.rowHeight = 88.0

or use the event heightForRowAt where u have the IndexPath for the cell

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
       return 88.0
}
Kassem Itani
  • 1,057
  • 10
  • 15