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

View file

@ -272,6 +272,13 @@ private extension TableViewController {
if if
let item = update.maintainScrollPosition, let item = update.maintainScrollPosition,
let indexPath = self.dataSource.indexPath(for: item) { 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) self.tableView.scrollToRow(at: indexPath, at: .top, animated: false)
if let offsetFromNavigationBar = offsetFromNavigationBar { if let offsetFromNavigationBar = offsetFromNavigationBar {