Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 11 refresh control + search bar = missing spinner when refreshing

I'm trying to use the standard UIRefreshControl and UISearchController on a UITableViewController. However it doesn't look like it does what it's supposed to. When refreshing, scrolling leaves the navigation bar with a big blank area, presumably where the spinner is supposed to be:

enter image description here

I have a sample project on GitHub. Here's how the controls are set up:

override func viewDidLoad() {
    super.viewDidLoad()

    let spinner = UIRefreshControl()
    spinner.addTarget(self, action: #selector(refresh), for: .valueChanged)
    refreshControl = spinner

    searchController = UISearchController(searchResultsController: nil)
    navigationItem.searchController = searchController
}

I've tried assigning the refresh control to the property on UITableView instead of the one on UITableViewController, that doesn't make a difference.

Has anyone come across the same issue?

like image 599
Allen Zeng Avatar asked Oct 17 '17 12:10

Allen Zeng


1 Answers

You can use UIRefreshController in the old way, which is like this:

override func viewDidLoad() {
    super.viewDidLoad()

    let spinner = UIRefreshControl()
    spinner.addTarget(self, action: #selector(refresh), for: .valueChanged)
    self.tableView.addSubview(spinner)

    searchController = UISearchController(searchResultsController: nil)
    navigationItem.searchController = searchController
}
like image 62
Seyed Samad Gholamzadeh Avatar answered Nov 17 '22 22:11

Seyed Samad Gholamzadeh