浏览代码

scroll to top on cancel search

nayooti 5 年之前
父节点
当前提交
eafe2e2871
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      deltachat-ios/Controller/ChatListController.swift

+ 8 - 0
deltachat-ios/Controller/ChatListController.swift

@@ -356,5 +356,13 @@ extension ChatListController: UISearchBarDelegate {
 
     func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
         viewModel.endSearch()
+        DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
+           self.tableView.scrollToTop()
+        }
+    }
+
+    func searchBar(_ searchBar: UISearchBar, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
+        tableView.scrollToTop()
+        return true
     }
 }