I'm having a weird issue where an UIRefreshControl
is glitching when I use it in combination with an UITableView
and custom UITableViewCells
. If I use basic ones (set in the inspector panel in Xcode) it works just fine. See GIFs on Imgur.
override func viewDidLoad() {
super.viewDidLoad()
navigationController?.navigationBar.prefersLargeTitles = true
refreshControl = UIRefreshControl()
refreshControl?.addTarget(self, action: #selector(self.refresh), for: .valueChanged)
tableView.refreshControl = refreshControl
refresh()
}
@objc func refresh() {
tableView.reloadData()
refreshControl?.endRefreshing()
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 8
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell")
return cell!
}
Settings in inspector on UITableView and UITableViewCell are default. I'm having this issue in multiple project. The code above is in a clean project. The refresh control also jumps when prefersLargeTitles = false
.
How do I get the refresh control to behave correctly with a custom TableViewCell?