How to make last row to cover the remaning unoccupied space of tableview

172 Views Asked by At

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
1

There are 1 best solutions below

0
Govind Rakholiya On BEST ANSWER

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.