【发布时间】:2018-04-19 13:07:50
【问题描述】:
我有两个类TableViewController 和CustomCell 然后将IB 中的按钮(likeBtn) 连接到CustomCell。
现在,我想更改此按钮的图像!
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cellIdentifier = "Cell"
let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as! CustomCell
// Configure the cell...
cell.likeBtn.addTarget(self, action: #selector(TableViewController.liked), for: .touchUpInside)
return cell
}
@objc func liked(sender: UIButton) {
cell.likeBtn.setImage(UIImage(named: "liked.png"), for: .normal)
cell.likeBtn.isUserInteractionEnabled = false
}
但是在liked() 中,我有关于cell.likeBtn 的错误。
我正在使用 swift 4
进行编程【问题讨论】:
标签: swift uitableview button cell