iOS 13 UISearchController + UIRefreshControl glitch
Asked Answered
S

1

6

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

Skewback answered 11/9, 2019 at 11:35 Comment(0)
A
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.

Alecto answered 14/9, 2019 at 11:45 Comment(1)
Not sure if that is an option, but good to know anyways, thanksSkewback

© 2022 - 2024 — McMap. All rights reserved.