简体   繁体   中英

Refresh Control is not refreshing tableView properly

I have set up a refresh control but its not working, I did try to reloadData() in tableView, ill provide my code if there is a mistake:(

Its not reloading nothing in tableView

 @objc private func refreshListData(_ sender: Any) {
    self.monitorimiTableView.reloadData()
    self.pullControl.endRefreshing()
}

override func viewDidLoad() {
    super.viewDidLoad()
    pullControl.bounds = CGRect(x: 0, y: 50, width: pullControl.bounds.size.width, height: pullControl.bounds.size.height)
    pullControl.attributedTitle = NSAttributedString(string: "")
    pullControl.addTarget(self, action: #selector(refreshListData(_:)), for: .valueChanged)  
}

    if #available(iOS 10.0, *) {
        tableView.refreshControl = pullControl
    } else {
        tableView.addSubview(pullControl)
    }
let refreshControl = UIRefreshControl()
override func viewDidLoad() {
super.viewDidLoad()
  refreshControl.attributedTitle = NSAttributedString(string: "Pull to refresh")
 refreshControl.addTarget(self, action: #selector(self.refresh(_:)), for: .valueChanged)
 tableView.addSubview(refreshControl) // not required when using UITableViewController
}
@objc func refresh(_ sender: AnyObject) {
 // Code to refresh table view  
refreshControl.endRefreshing()
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM