iOS 13下UISearchController + UIRefreshControl出现故障。

6
我正在使用UISearchController进行搜索,并在支持下拉刷新的UITableViewController中使用UIRefreshControl
在一个简化的演示项目中,设置非常简单。
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),刷新动画已损坏。

enter image description here

迄今为止,我发现的唯一“解决方法”是将navigationItem.hidesSearchBarWhenScrolling设置为false,但这显然会导致搜索栏始终停留在屏幕上,即使滚动也是如此。以下是演示此问题的示例项目:https://github.com/iv-mexx/UISearchControl-UIRefreshControl-iOS13-Bug/tree/feature/ios13更新:Xcode 11 GM Seed 2中仍存在此问题。
1个回答

2

如果打开应用程序的大标题选项,这似乎也可以解决问题。

这可能是为什么苹果在自己的应用程序中没有遇到这个问题的原因。


不确定是否有这个选项,但无论如何还是很好知道,谢谢。 - MeXx

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接