CuriousMan
CuriousMan

Reputation: 52

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

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

Upvotes: 0

Views: 198

Answers (1)

Govind Rakholiya
Govind Rakholiya

Reputation: 467

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.

Upvotes: 2

Related Questions