I have got a table in my Swift project like this
var tableView: UITableView!
tableView = UITableView()
tableView.dataSource = self
tableView.delegate = self
ta
I had problems with constraints so here is what i did.
First i added heightForRowAt
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 100
}
Then i created a variable
let tableViewHeight = postTexts.count*100
And put that in my height constraint
tableView.anchor(PostsDiv.bottomAnchor, left:view.leftAnchor, bottom: nil, right: view.rightAnchor, topConstant: 40, leftConstant: 15, bottomConstant: 0, rightConstant: 15, widthConstant: 0,heightConstant: CGFloat(tableViewHeight))
And it works pretty well for me