Ich habe ein Problem mit dem Häkchen für eine Zeile in iOS-Tabellenansicht Wenn ich ein Element oben auswählen, wird auch das nächste 13. Element ausgewählt, ich weiß nicht warum?Multi-Auswahl funktioniert nicht richtig in IOS
Muss ich etwas mit der Tabelle machen, bevor ich das Häkchen gesetzt habe, weil ich nur eine Bedingung überprüfe und wenn diese Bedingung zutrifft, setze ich den accessoryType als Häkchen, unten steht der Code.
Hinweis: - In diesem Fall wird die 13. Zeile nicht ausgewählt, sondern nur der Zubehörtyp dieser Zeile geändert.
if let cell = tableView.cellForRowAtIndexPath(indexPath) {
if cell.selected {
if(self.sections[indexPath.section].files[indexPath.row].type != "cloud"){
print(self.sections[indexPath.section].files[indexPath.row])
cell.accessoryType = .Checkmark
NSNotificationCenter.defaultCenter().postNotificationName("enableOptions", object: nil)
}
}
}
CellForIndexPath Code:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! MyFilesTableViewCell
let fileSection = sections[indexPath.section]
let file = fileSection.files[indexPath.row]
cell.title.text = file.name
if file.timeStamp.isEmpty{
cell.timeStamp.hidden = true
}else{
cell.timeStamp.hidden = false
cell.timeStamp.text = file.timeStamp
}
cell.icon.image = file.icon
cell.actionsBtn.row = indexPath.row
cell.actionsBtn.section = indexPath.section
cell.actionsBtn.setTitle("\u{f142}", forState: .Normal)
cell.actionsBtn.addTarget(self, action: #selector(MyFilesTableViewController.buttonClicked(_:)), forControlEvents: UIControlEvents.TouchUpInside)
if(editingTable){
cell.actionsBtn.hidden = true
}else{
cell.actionsBtn.hidden = false
}
if(file.type == "cloud"){
cell.actionsBtn.hidden = true
}
cell.progressBar.progress = 0.0
cell.progressBar.hidden = true
return cell
}
Sie können den cellforrowatindex-Pfadcode –
eingeben Das Problem besteht hier in der UITableView-Eigenschaft zur Wiederverwendung von Zellen. Ich hoffe, Sie verwenden Prototypzellen. Wenn ja, lass es mich wissen – KrishnaCA
http://stackoverflow.com/questions/40057655/ios-swift-uiimageview-change-image-in-tableview-cell/40058685#40058685 Beantworten Sie diese Antwort @aoxi –