Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

enter image description here

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

like image 214
MeXx Avatar asked Sep 11 '19 11:09

MeXx


1 Answers

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.

like image 152
Kay Avatar answered Sep 18 '22 14:09

Kay