Ram
Ram

Reputation: 868

How to set Dynamically UITableView height in Swift?

How to set Tableview height dynamically like in android. i tried with following code, but its not working.

 tblHeightConstraint.constant = downSelectionTbl.contentSize.height

see this below link i tired upvote answers even though its not resolved my issue.

iOS: Dynamically set UITableView height in Swift

Upvotes: 1

Views: 7525

Answers (1)

Venk
Venk

Reputation: 5955

Do like this,

func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
    tblHeightConstraint.constant = downSelectionTbl.contentSize.height
}

Upvotes: 10

Related Questions