I tried to add a refresh control on my table view but I couldn't make it as I wanted.
I have a view that contains, among other things, a table view. My ViewController's viewDidLoad function is the following:
override func viewDidLoad() {
super.viewDidLoad()
// set the refresh control
self.refreshControl = UIRefreshControl()
self.refreshControl.attributedTitle = NSAttributedString(string: "Pull to refresh")
self.refreshControl.addTarget(self, action: "getData", forControlEvents: UIControlEvents.ValueChanged)
self.tableView.addSubview(refreshControl)
}
Everything works except that when I pull down the rows to triggers the refresh control, the refresh control appears BEHIND the first row and ends up on top of the first row (normal, I'm pulling those rows down...).
What I would like to get is like in many apps, when you pull down your rows, the refresh control acts like if it was the row #-1 and unhide from the top as soon as we are pulling down the first row.
Is that possible with the built-in refresh control?
Thanks