Swift UITableView: 获取选中 Cell 内容 (didSelectRowAt)
在 Swift 中,我们可以使用 'tableView(_:didSelectRowAt:)' 方法来获取到被选中的 cell。在这个方法中,我们可以使用 'tableView.cellForRow(at:)' 方法来获取到指定 indexPath 位置的 cell。下面是一个例子:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// 获取到被选中的 cell
let cell = tableView.cellForRow(at: indexPath)
// 进行其他操作
// ...
}
在这个例子中,我们通过 'tableView.cellForRow(at:)' 方法获取到了被选中的 cell,并将其赋值给了 'cell' 常量。然后我们可以对这个 cell 进行其他操作,例如修改其样式、内容等。
原文地址: https://www.cveoy.top/t/topic/pSue 著作权归作者所有。请勿转载和采集!