Add content inset bottom to maintain position

This commit is contained in:
Justin Mazzocchi 2020-10-25 18:35:22 -07:00
parent fa1487df16
commit c7e4186749
No known key found for this signature in database
GPG Key ID: E223E6937AAFB01C
1 changed files with 7 additions and 0 deletions

View File

@ -272,6 +272,13 @@ private extension TableViewController {
if
let item = update.maintainScrollPosition,
let indexPath = self.dataSource.indexPath(for: item) {
self.tableView.contentInset.bottom = max(
0,
self.tableView.frame.height
- self.tableView.contentSize.height
- self.tableView.safeAreaInsets.top
- self.tableView.safeAreaInsets.bottom)
+ self.tableView.rectForRow(at: indexPath).minY
self.tableView.scrollToRow(at: indexPath, at: .top, animated: false)
if let offsetFromNavigationBar = offsetFromNavigationBar {