【发布时间】:2019-07-30 01:59:26
【问题描述】:
我想实现 UITableView 我想在每个 UITableViewCell 中有 3 个按钮。我想为每个按钮执行不同的操作。如何识别按下哪个按钮,然后获取所选单元格的对象(索引行)?
UIViewController
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let show=shows[indexPath.row]
let cell = tableView.dequeueReusableCell(withIdentifier: "ShowCell") as!
ShowCell
cell.setShow(show: show)
return cell
}
UITableViewCell
@IBOutlet weak var graphButton: FlatButton!
@IBOutlet weak var buyButton: FlatButton!
@IBOutlet weak var reviewButton: FlatButton!
func setShow(show :StubHubEvent ){
let url = URL(string: show.imageurl)!
showImageView.af_setImage(withURL: url)
showImageView.contentMode = .scaleAspectFill
showImageView.clipsToBounds = true
nameLabel.text = show.title
dateLabel.text = show.time
【问题讨论】:
标签: ios swift uitableview uibutton