【发布时间】:2020-09-08 02:50:16
【问题描述】:
我正在尝试使用 NFC 阅读器会话将图像添加到我的 tableview 单元格。所以,我的问题是,每次第一次阅读器会话,我都会在图像视图中获得正确的图像,但是当我第二次尝试阅读器会话时,我在表格视图的两个单元格上都遇到了两个相同的最后分配的图像。我知道它是因为 tableView.dequeueReusableCell 方法,但我不确定使用哪种方法来获取正确的图像不正确的单元格。
我还附上了一张截图,以更清楚地说明我的意思。
代码如下:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "TableViewCell", for: indexPath) as! TableViewCell
cell.nfcModel = arrData[indexPath.row]
// IMG CELL
cell.img.image = UIImage(named: name)
return cell
}
【问题讨论】:
-
对不起,我无法解决 NFC 问题,我在 tableView 以及如何显示来自 Web API 的数据方面做了很多工作
-
希望代码示例有所帮助
标签: ios swift xcode uitableview nfc