【发布时间】:2022-01-09 03:04:39
【问题描述】:
我有一个接收字符串标识符数组的 TableView,我需要为我拥有的每个单元格设置一个标识符并将其关联到一个名为“cellPressedId”的变量,但是当我这样做时,我只是获取数组的最后一个值
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if let selectedCell = tableView.cellForRow(at: indexPath) {
if let selectedCell = tableView.cellForRow(at: indexPath) {
var cellPressed = self.cellPressedId
}
}
我需要做的是为每个单元格设置这个标识符,当我按下这个单元格时获取标识符
【问题讨论】:
-
在某些时候,你不做
let identifier = myArray[indexPath.row]in tableView(_/cellForRowAt:)`吗?设置标识符?为什么不在这里做同样的事情?