Refresh Control on top of tableview when I go back to view controller

uicollectionview pull to refresh
pull to refresh uiview swift
custom uirefreshcontrol
uirefreshcontrol overlap
uiscrollview refreshcontrol
uirefreshcontrol selector not called
uirefreshcontrol flickering

For some reason, the first time the view controller is loaded, the refresh control behaves as expected (that it, showing under tableview when swipe down). The problem is when I tap on another tab, and then go back to the view controller, the refresh control does not fade in anymore and is visible on top of the tableview.

This is part of the code:

class CoreTableViewController : UIViewController, UITableViewDataSource, UITableViewDelegate {

var tableView:UITableView!
var tableData:Array<AnyObject> = []
var dataFetched:Bool = false
var refreshControl:UIRefreshControl?

override func viewDidLoad() {

    self.edgesForExtendedLayout = UIRectEdge.None;

    self.tableView = self.assignTableView()
    self.tableView.delegate = self
    self.tableView.dataSource = self
    self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell")
    self.tableView.separatorStyle = UITableViewCellSeparatorStyle.None;

    if self.enableRefresher() {

func enableRefresher() -> Bool {
    return true

func fetchData(cleanFirst:Bool = false) {
    // Fetch data.

func refresh() {

func setRefreshControl() {
    self.refreshControl = UIRefreshControl()
    //self.refreshControl!.attributedTitle = NSAttributedString(string: "Actualizar")
    self.refreshControl!.addTarget(self, action: #selector(CoreTableViewController.refresh), forControlEvents: UIControlEvents.ValueChanged)


Any thoughts?

I found the fix here:

Instead of self.tableView.addSubview(refreshControl!), it should be self.tableView.insertSubview(refreshControl!, atIndex: 0).

That was causing the refres control to appear over the tableview.

Pull to Refresh iOS Tutorial, How do you implement pull to refresh in Swift 4? When pushing some ViewControllers, then press home button, and go back and pop back, the UIRefreshControl is always on the top. Finally I use this code temporarily avoid it. (Ugly but stops it always shows on top)

Try this,

The Above solutions are fine but tableView.refreshControl is available for UITableViewController only, till iOS 9.x and comes in UITableView from iOS 10.x onwards.

To fix this Just use :

Written in Swift 3 -

let refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action: #selector(FeedViewController.loadNewData), for: UIControlEvents.valueChanged)
// Fix for the RefreshControl Not appearing in background
tableView.sendSubview(toBack: refreshControl)

How to Add Pull-to-Refresh to a Table View or Collection View, tap on another tab, and then go back to the view controller, the refresh control does not fade in anymore and is visible on top of the tableview. This is part of the​  When i go from view2 back to view1 i need view1 to reload data from server. This site uses cookies for analytics, personalized content and ads. By continuing to browse this site, you agree to this use.

As I examine your code and your question, I think the problem is here:

"In addition to assigning a refresh control to a table view controller’s refreshControl property, you must configure the target and action of the control itself."

So, from documentation, you need to use UITableViewController, not UIViewController. And set it's refreshControl property.

In the current state, you just add UIRefreshControl as regular subview.

Pull-to-Refresh : How to implement in iOS Swift 3., When pulled, a little wheel starts spinning at the top, until the refresh has completed. At that time, the wheel disappears, and the view bounces back into place. In this tutorial a refresh control will be added to a table view. When the control Select the Navigation Controller and go to The Attribute inspector. First, we’re Control-dragging from the table view cell to the detail view controller. This will create the segue between the cell and the destination view controller. This will create the segue between the cell and the destination view controller.

It looks ok, I suspect it's because some race condition regarding the creation of the control itself. I found out that using lazy properties helps a lot in this cases. I'll do something like this:

lazy var refreshControl: UIRefreshControl = {
    let refreshControl = UIRefreshControl()
    refreshControl.addTarget(self, action:#selector(CoreTableViewController.refresh(_:)), forControlEvents: .ValueChanged)
    return refreshControl

override public func viewDidLoad() {
    if self.enableRefresher() {

func refresh(refreshControl: UIRefreshControl) {

You don't need to use a TableViewController, an UIViewController is enough and more often than not more flexible.

Hope it helps

How To Add a Pull-to-Refresh Feature in Your , Let's start by adding a refresh control to the table view. Declare a private constant property at the top and assign an instance of the Navigate to the setupTableView() method of the ViewController class and add the  Say page A shows a list of items, the headerbar shows an "ADD" button. When I press this ADD button I go to page B where I can add a new item to the list.

Unfortunately, no one solution above has helped me.

In my case, a refresh control appears after reloading a table view when the table view is empty. Maybe if the table view has at least one row it simply hides the refresh control, I haven't checked it. Also, when my view controller appears again it works like a workaround and it hides the refresh control.

But I've found another workaround to hide the refresh control immediately. An async call is mandatory here.

DispatchQueue.main.async {

I was inspired by this answer in another post.

iOS UIRefreshControl on UITableView, Lots of iOS apps have Pull-to-Refresh feature with nice… Then create a reference for TableView to the ViewController.swift. 6. Here our return refreshControl }() Next step is to add the UIRefreshControl object to the UITableView object. These UIScrollView categories makes it super easy to add pull-to-refresh and infinite scrolling fonctionalities to any UIScrollView (or any of its subclass). Instead of relying on delegates and/or subclassing UIViewController , SVPullToRefresh uses the Objective-C runtime to add the following 3 methods to UIScrollView :

Refresh Control Changes in iOS 10, When I answer, “Why don't use the Apple refresh control already embedded? open-source library available to manage the UITableView refresh. Now go on Storyboard, delete the ViewController , and add a UITableViewController . Go back on Storyboard, select the TableViewController , and enable  Lastly, we have to establish the connection between the Table View and the two methods we just created. Go back to the Storyboard. Press and hold the Control key on your keyboard, select the “Table View” and drag to the View Controller icon. Your screen should look like this:

Uitableview scroll to top after reload swift, You must have seen very often a spinning wheel when you pull the top of Since iOS 10, UITableView consists of a refreshControl property which makes it In the Main.storyboard, add a UITableView to the View Controller, set the constraints. We are still holding it while it goes back up which leads to a positive velocity. RefreshControl This component is used inside a ScrollView or ListView to add pull to refresh functionality. When the ScrollView is at scrollY: 0 , swiping down triggers an onRefresh event.

UIRefreshControl, Unfortunately it only worked with a table view controller. You were out of luck if you wanted to use it with a plain scroll view or collection views Apple first added the pull-to-refresh style user interface control way back in iOS 6  Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

  • Please elaborate it clearly, I do not understand what you want and what u getting
  • even with this, the refreshesControl is shown above the table starting ios 11.x (ios 9 works fine)
  • There is a simulator bug on iOS 11 but device works okay.
  • What about if you want to use a collection view? I have exactly the same problem with the refresh control inside a collection view.
  • @Ricardo, check out collection view documentation. Looks like UIRefreshControl is made exclusively for UITableView. Maybe you need to browse for already implemented solution or made it by yourself... Anyway it's a topic for different question.