Bartłomiej Semańczyk
Bartłomiej Semańczyk

Reputation: 61774

No apriopriate scroll when changing tableFooterView's frame

This is how I change tableFooterView loaded firstly from storyboard:

enter image description here

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?

enter image description here

Upvotes: 0

Views: 156

Answers (2)

Arsen
Arsen

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

Bartłomiej Semańczyk
Bartłomiej Semańczyk

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

Related Questions