The problem is that I have a table whose cells have dynamic height. Those. The cell is custom and in a storyboard its design is built on constraints. When loading a table from the Internet, the content is loaded, which is loaded into the array and then the table is updated and the cells are filled, and their height depends on the content and can vary greatly.
At first I ran into the problem that, due to the different heights, when updating one of the cells, the table scrolled a little. I was helped to solve this problem here.
And it would seem that the problem has been solved. But now I added a header to my table. And his height also changes dynamically. As I understand it, so that there is no shift and the table does not scroll when updating the cells, I need to add the following lines to viewDidLoad:
self.tableView.sectionHeaderHeight = UITableViewAutomaticDimension self.tableView.estimatedSectionHeaderHeight = ? But I need to know the height of the header. How to do it? If I do this:
override func tableView(tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) { self.tableView.estimatedSectionHeaderHeight = view.frame.height } then I get the height that I originally set myself in viewDidLoad. And I need the real height of the header, taking into account all the content that is there.