简体   繁体   English

UIRefreshControl不执行操作

[英]UIRefreshControl not doing action

So I have enabled refreshing for the table view in Storyboard and put this code into the viewDidLoad() : 因此,我在Storyboard中启用了表视图的刷新,并将此代码放入viewDidLoad()中:

refreshControl?.addTarget(self, action: #selector(ViewController.refresh(sender:)), for: .valueChanged)

and this is the refresh function: 这是刷新功能:

func refresh(sender: AnyObject) {
    print("a")
    self.tableView.reloadData()
    refreshControl?.endRefreshing()
}

The problem is that when I pull to refresh, it does not print "a"(put this for testing) and it does not end refreshing. 问题是,当我拉动刷新时,它不会打印“ a”(将此用于测试)并且不会结束刷新。 Why? 为什么?

Since you're already using Storyboards, try connecting your refresh control through IBActions (valueChanged) and see if it works. 由于您已经在使用Storyboards,请尝试通过IBActions(valueChanged)连接刷新控件,然后查看它是否有效。 Follow this link for a guide 点击此链接获取指导

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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