【发布时间】:2016-03-13 23:53:36
【问题描述】:
我有一个表格视图单元格,每个单元格中都有类似按钮。
我想让用户点击单元格的like按钮,它会改变按钮图像。
这是我的代码:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Result", forIndexPath: indexPath) as! ResultTableViewCell
cell.likebutton.tag = indexPath.row
return cell
}
和功能
@IBAction func printTag(sender: AnyObject) {
let cell = tableView.dequeueReusableCellWithIdentifier("Result", forIndexPath: indexPath) as! ResultTableViewCell
cell.likebutton.setImage(UIImage(named: "clicklike"), forState: UIControlState.Normal)
}
有什么办法吗?
【问题讨论】:
-
解决什么问题?你还没有说明你的问题是什么。
-
我的问题是,当我点击按钮时,图像不会改变,功能也不起作用:(
标签: ios swift uitableview