UIRefreshControl is flickering and transitions are abrupt

Viewed 538

I'd like to set up a UIRefreshControl in my apps' main table view controller to trigger a refresh function to (you probably guessed it by now) refresh it.

Adding it isn't the problem, I'm able to set it up through the storyboard (by enabling refreshing) or in the controller (by using self.refreshControl = UIRefreshControl()).

When it gets triggered by the user it starts refreshing normally, but when I trigger it through self.refreshControl.beginRefreshing() the control isn't displayed in the navigation bar, until I scroll down (like you would normally trigger it)

But that's not even the weirdest part. When it's finally visible to the user there is a constant flicker to it and after a while it's not visible at all.

For the self.refreshControl.endRefreshing() method, the animation is really abrupt any choppy and sometimes the navigation bar doesn't scroll up again (leaving an empty space at the top)

Here is a gif, that should summarise my problem

I use swift 4.2, the application was tested on different simulators (running iOS 12.1) and my iPhone X (running iOS 12.1.2) and the release target is iOS 10.0.

I've already done research on my problem, but no one seems to have the exact issue (at least the flickering) or the solutions don't work for me.

This is how my view controller is set up:

class MyViewController: UITableViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
    
        self.refreshControl = UIRefreshControl()
        self.refreshControl?.addTarget(self, action: #selector(reload), for: .valueChanged)
        
        self.refreshControl.beginRefreshing()
    }


    @objc func reload() {
    
        DispatchQueue(label: "update").async {

            sleep(10)
        
            DispatchQueue.main.async {
                self.refreshControl?.endRefreshing()
            }
        }
    }
}

Thanks for reading, I really hope someone can help me.

Update

I just discovered that the issue only occurs with a non-translucent navigation bar with large title, so picking a translucent navigation bar instead of the opaque is a solution (sadly not one I would like to live with). Maybe someone has an approach to having a functional refresh control with an opaque navigation bar.

Additionally I submitted a bug report to Apple, because something like that should not happen in the first place, I'll update this post when they get back to me.

0 Answers
Related