I have navigation bar controller and inside one of the tab table view controller with pull down refresh action to refresh data from server.
When I start app and load view first time it works ok, but if I switch tab and come back action method isn't fired again, only spinner is spinning.
Here is some of the code used in my class that is extending UITableViewController:
//this is as class property:
let refresh = UIRefreshControl()
//inside viewDidLoad()
refresh.addTarget(self, action: #selector(reload), for: .valueChanged)
self.refreshControl = refresh
//and to manually fire reload action:
self.refreshControl?.beginRefreshing()
reload()
//inside viewWillAppear()
refresh.addTarget(self, action: #selector(reload), for: .valueChanged)
self.refreshControl = refresh
//these two lines have no effect whatsoever, even if I remove them nothing changes...
//and reload method:
@objc func reload()
{
print("reload")
fetchData()
}
reload() doesn't get called after switching tabs so user cannot manually reload data from server anymore.