我正在使用UISearchControllerfor 搜索,UITableViewController它也支持通过UIRefreshControl.
在简化的 Demo 项目中设置非常简单
override func viewDidLoad() {
extendedLayoutIncludesOpaqueBars = true
title = searchTerm ?? "Search"
super.viewDidLoad()
setupSearch()
setupRefresh()
}
private func setupSearch() {
searchController.searchResultsUpdater = self
navigationItem.searchController = searchController
definesPresentationContext = true
//
// If this is set to `true` (which is also the default),
// UISearchBar and UIRefreshcontroll are buggy
//
navigationItem.hidesSearchBarWhenScrolling = true
}
private func setupRefresh() {
refreshControl = UIRefreshControl()
refreshControl?.addTarget(self, action: #selector(refresh), for: .valueChanged)
}
这在 iOS 12 中有效,但现在在 iOS 13(使用 Xcode 11 GM 为 iOS 13 编译)中,刷新动画被破坏
到目前为止,我发现的唯一“修复”是设置navigationItem.hidesSearchBarWhenScrolling为false,但这显然会导致搜索栏始终停留在屏幕上,即使在滚动时也是如此。
这是一个演示该问题的示例项目:https ://github.com/iv-mexx/UISearchControl-UIRefreshControl-iOS13-Bug/tree/feature/ios13
更新:这在 Xcode 11 GM Seed 2 中仍然存在问题
