【发布时间】:2019-05-22 09:00:54
【问题描述】:
我创建了一个包含按钮的自定义单元格,我需要创建从这个按钮到其他 VC 的 segue,但首先,我想用那个 segue 推送一个对象。
我已经尝试使用 cell.button.tag,但没有成功。
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showMap" {
let mapVC = segue.destination as! MapViewController
//guard let indexPath = tableView.indexPathForSelectedRow else { return }
mapVC.place = places[] // <- "here I need index of button in cell"
}
}
【问题讨论】:
-
您可以使用委托方法
didSelectItemAt indexPath并且所选单元格的indexPath 将是已知的,或者使用手势识别器而不是segue。
标签: ios swift uitableview