0

I have a tableview , it has two rows.

Tableview's height is 700. The first row height is 150 and the second row height is 100 but I'd like the second cell to cover the rest of the space in tableview.

I know I can use the below for tableview height. But I'd like to

override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
CuriousMan
  • 42
  • 11
  • 3
    Take a look at this: https://stackoverflow.com/questions/36501276/how-to-make-last-row-of-uitableview-fill-the-empty-space – MarkWalczak Sep 07 '21 at 05:30
  • Simply calculate by TableViewheight-firstCellHeight will give height for 2nd Cell to fill whole TabelView – Kudos Sep 07 '21 at 05:50

1 Answers1

2

Simply, just replace this method

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    
    let tblHeight = infoTable.bounds.size.height
    return indexPath.row == 0 ? 150 : tblHeight - 150
    
}

just change infoTable with your table name.

Govind Rakholiya
  • 427
  • 6
  • 24