【发布时间】:2019-06-05 19:48:05
【问题描述】:
我在表格视图中创建了一个小型“通知中心”。但不知何故,图像在重复,这不是它应该的方式。
我自己也搞不清楚是什么原因,所以请大家帮忙。
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let listPath = list[indexPath.row]
let cell = tableView.dequeueReusableCell(withIdentifier: "ListCell") as! HistoryCell
cell.setCell(list: listPath)
print(cell.note.text!)
//THIS ONE
if cell.note.text!.isEmpty == false
{
cell.noteImg.isHidden = false
}
return cell
}
这是我的部分代码。所以让我解释一下这实际上是如何工作的。
每次用户将数据添加到特定文本字段时,都应将其添加到 Firestore 的“注释”中。
我从 Firestore 中选择所有内容以将数据插入到此 UITableView 中,并且如果“注释”不为空。我的图像应该是可见的。
我现在得到的结果: 即使值为零,它也会重复添加。
正如您在图片中看到的那样。 第一个(1)是正确的。 (12:55的那个) 但第二个不应该在那里,它只是随机添加的。
我真的希望你能理解,保持简短和有条理并不容易。
编辑:
func setCell(list: listTxt){
DogName.text = list.dog
Person.text = list.person
Action.text = list.action
Date.text = list.date
Time.text = list.time
timer.text = list.timer
kilometer.text = list.kilometers
documentID.text = list.documentID
latitude = list.latitude
longitude = list.longitude
note.text = list.note
noteImg.image = list.noteImg
}
【问题讨论】:
-
请贴出setCell方法的内容
-
@iMHiteshSurani 你去吧
标签: ios swift google-cloud-firestore