In my table view controller, i have implemented pull to refresh (UIRefreshControl). The problem is that I do not know why it is mix with the tableView (UITableViewController). For details, see the screenshot. Thank you for your assistance!
Asked
Active
Viewed 3,933 times
2
-
You'll need to provide more detail (code where you're adding the refresh control etc) – shim Apr 03 '15 at 16:06
-
Its happens when i go to another controller, and return back – mazorati Apr 03 '15 at 18:26
-
Can you show the code you are using to set up the refresh control. – Fogmeister May 12 '16 at 12:26
2 Answers
3
You can implement refresh control like this.
class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
@IBOutlet var tableView: UITableView!
var refreshControl : UIRefreshControl!
}
override func viewDidLoad() {
super.viewDidLoad()
self.refreshControl = UIRefreshControl()
self.refreshControl.backgroundColor = UIColor.clearColor()
self.refreshControl.tintColor = UIColor.blackColor()
self.refreshControl.addTarget(self, action: "methodPullToRefresh:", forControlEvents: UIControlEvents.ValueChanged)
self.tableView.addSubview(self.refreshControl)
}
func methodPullToRefresh(sender:AnyObject)
{
self.refreshControl?.beginRefreshing()
}
// Once you are done with your task
self.refreshControl?.endRefreshing()
// Main queue thread is only required when refresh controls comes or goes off with delay, if it works quickly then no need to add this
dispatch_async(dispatch_get_main_queue()) {
}
Hope, this will resolve your problem.
All the best.

Hasya
- 9,792
- 4
- 31
- 46
-
please check this question --> https://stackoverflow.com/q/67056902/15466427 – coceki Apr 13 '21 at 05:33
0
I had a similar problem and I solved it so:
When adding Refresh Controller on View Controller it is necessary to write the following code:
dispatch_async(dispatch_get_main_queue()) {
self.refreshControl.beginRefreshing()
self.refreshControl.endRefreshing()
}

Ilia Khalyapin
- 148
- 1
- 7