我有两个表视图,其中包含独立实现Pull to Refresh的想法。
首先我这样做了:
let refreshControl = UIRefreshControl()
refreshControl.attributedTitle = NSAttributedString(string: "Pull to refersh")
refreshControl.addTarget(self.tableView1, action:"refresh:", forControlEvents: UIControlEvents.ValueChanged)
refreshControl.addTarget(self.tableView2, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged)
self.tableView1.addSubview(refreshControl)
self.tableView2.addSubview(refreshControl)
但是,在运行时执行期间,出现了关于无法识别的选择器的错误:
[UITableView refresh:]: unrecognized selector sent to instance
答案 0 :(得分:1)
只需更改此行:
refreshControl.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged)
只有一个目标“指向”自我。
我希望它有所帮助。
干杯