Преглед изворни кода

fix scroll position for long messages when keyboard appears

cyberta пре 3 година
родитељ
комит
01d0ccedb7
1 измењених фајлова са 4 додато и 4 уклоњено
  1. 4 4
      deltachat-ios/Chat/ChatViewController.swift

+ 4 - 4
deltachat-ios/Chat/ChatViewController.swift

@@ -1075,7 +1075,7 @@ class ChatViewController: UITableViewController {
                 guard let self = self else { return }
                 guard let self = self else { return }
                 let numberOfRows = self.tableView.numberOfRows(inSection: 0)
                 let numberOfRows = self.tableView.numberOfRows(inSection: 0)
                 if numberOfRows > 0 {
                 if numberOfRows > 0 {
-                    self.scrollToRow(at: IndexPath(row: numberOfRows - 1, section: 0), animated: animated, focusWithVoiceOver: focusOnVoiceOver)
+                    self.scrollToRow(at: IndexPath(row: numberOfRows - 1, section: 0), position: .bottom, animated: animated, focusWithVoiceOver: focusOnVoiceOver)
                 }
                 }
             }
             }
         }
         }
@@ -1127,9 +1127,9 @@ class ChatViewController: UITableViewController {
         }
         }
     }
     }
 
 
-    private func scrollToRow(at indexPath: IndexPath, animated: Bool, focusWithVoiceOver: Bool = true) {
+    private func scrollToRow(at indexPath: IndexPath, position: UITableView.ScrollPosition = .top, animated: Bool, focusWithVoiceOver: Bool = true) {
         if UIAccessibility.isVoiceOverRunning && focusWithVoiceOver {
         if UIAccessibility.isVoiceOverRunning && focusWithVoiceOver {
-            self.tableView.scrollToRow(at: indexPath, at: .top, animated: false)
+            self.tableView.scrollToRow(at: indexPath, at: position, animated: false)
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.25, execute: { [weak self] in
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.25, execute: { [weak self] in
                 guard let self = self else { return }
                 guard let self = self else { return }
                 UIAccessibility.post(notification: .screenChanged, argument: self.tableView.cellForRow(at: indexPath))
                 UIAccessibility.post(notification: .screenChanged, argument: self.tableView.cellForRow(at: indexPath))
@@ -1137,7 +1137,7 @@ class ChatViewController: UITableViewController {
                 self.updateScrollDownButtonVisibility()
                 self.updateScrollDownButtonVisibility()
             })
             })
         } else {
         } else {
-            self.tableView.scrollToRow(at: indexPath, at: .top, animated: animated)
+            self.tableView.scrollToRow(at: indexPath, at: position, animated: animated)
         }
         }
     }
     }