Reputation: 61774
This is how I change tableFooterView loaded firstly from storyboard:
At some time I change tableFooterView
and assign a newContentSize to tableView
:
self.tableView.tableFooterView?.frame.size.height = 400
var newContentSize = self.tableView.contentSize
newContentSize.height += 400
self.tableView.contentSize = newContentSize
but it is not working, because scroll ends and tableFooterView is out of scroll. Why?
Upvotes: 0
Views: 156
Reputation: 10951
let newTableFooterView = self.tableView.tableFooterView
newTableFooterView.frame.size.height = 400
self.tableView.tableFooterView = newTableFooterView
Re-assign your footer view to the table. The table will recognize it has a new footer and re-do whatever layout needs to occur for the proper size of the footer.
Upvotes: 1
Reputation: 61774
If we change tableFooterView
's frame, the tableView
is not aware of that, so its contentSize
won't change properly. All it needs to be done is assign completely new tableFooterView
:
let newTableFooterView = self.tableView.tableFooterView
newTableFooterView.frame.size.height = 400
self.tableView.tableFooterView = newTableFooterView
Upvotes: 1