Wenn ich Zeile von TableView auswählen (klicke), sollte Image hinzufügen, dass ich dieses bestimmte Element ausgewählt habe. Es funktioniert gut!UITableView-Zelle bei Doppelklick sollte zum vorherigen Zustand wechseln
Mein Problem ist: wenn Benutzer von diesem ausgewählten Element zurückgehen möchten. Wenn ich auf dieselbe Zeile klicke, sollte ich die Zelle abwählen und das Bild ausblenden.
Was ich versucht ist:
func tableView (_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return tableData.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath as IndexPath) as! leistungCell
// Configure the cell...
let tableData = self.tableData[indexPath.row]
cell.leistungLbl.text = tableData["leistung_info"] as? String
//space between Rows
cell.contentView.backgroundColor = colorLightGray
cell.contentView.layer.borderColor = UIColor.white.cgColor
//space between Rows
cell.contentView.layer.borderWidth = 3.0
cell.contentView.layer.cornerRadius = 8
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let cell = tableView.cellForRow(at: indexPath)
cell?.imageView?.image = UIImage(named: "check.png")
let value = Info["leistung_info"] as! String
}
func tableView(_ tableView: UITableView, didDeSelectRowAt indexPath: IndexPath){
let cell = tableView.cellForRow(at: indexPath)
cell?.imageView?.image = nil
}
welches Problem konfrontiert? – KKRocks
@KKRocks, wenn ich wieder auf die selbe Zelle klicke, die ich vorher ausgewählt hatte, wird das Bild nicht gehen. Es wird immer noch sichtbar sein. Ich möchte, dass dieses Bild sich vor dieser Zelle versteckt. –
Sie müssen Zelle nach Zelle neu laden? .imageView? .image = nil. – KKRocks