I am working on an app where the user can create game lists and i have managed to create he scene where the user can see the details of the list (Title and description) and get an overview of the games added in a UITableView.
When the user has added games to the tableView i resize the table and the scrollView content size to easily display all the games with the ScrollView. The problem lies in that the didSelectRowAt function is only called by the first two cells!! And i can't understand why it does not work for the rest of the cells.
The code for resizing:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if gamesInList.count > 0 && gamesInList.count != previourCount {
previourCount = gamesInList.count
gamesTableView.isHidden = false
gamesInListTitle.isHidden = false
listEditButton.isHidden = false
// MARK: Resize views for the table view
let oldTableSize = gamesTableView.frame.size.height
print(gamesTableView.estimatedRowHeight)
// Resi
gamesTableView.frame = CGRect(x: gamesTableView.frame.origin.x, y: gamesTableView.frame.origin.y, width: gamesTableView.frame.size.width, height: CGFloat(gamesInList.count) * gamesTableView.estimatedRowHeight) // TODO Ond variabel!
scrollView.contentSize = CGSize(width: contentView.frame.size.width, height: scrollView.contentSize.height - oldTableSize + gamesTableView.frame.height)
gamesTableView.reloadData()
}
}
I thought it had something to do with the Content View inside the scrollView not resizing so i tried to resize it with code as well but it did not work anyway.
Update
So i have been debugging my problem for a while and i think i have found the real issue. The scrollView contentSize is resized correctly but the contentView is not resized and stays the same. Resizing it programmatically does nothing as it just keeps the original size