简体   繁体   中英

iOS 13 UISearchController + UIRefreshControl glitch

I'm using a UISearchController for search in a UITableViewController that also supports pull-to-refresh via UIRefreshControl .

The setup is very simple in a reduced Demo project

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)
}

This worked in iOS 12, but now in iOS 13 (compiled for iOS 13 with Xcode 11 GM), the Refresh Animation is broken

在此处输入图片说明

The only "fix" I have found so far is to set navigationItem.hidesSearchBarWhenScrolling to false , but this obviously causes the Searchbar to always stay on screen, even when scrolling.

Here is a sample project demonstrating the issue: https://github.com/iv-mexx/UISearchControl-UIRefreshControl-iOS13-Bug/tree/feature/ios13

Update: This still remains broken in Xcode 11 GM Seed 2

If turning on large titles is an option for your app, this seems to workaround the issue as well.

This might be why Apple isn't running into the issue in their own apps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM