I currently have a tableView
which I've created custom selection and deselection actions for (fade in and out a view). I am facing a problem where on unwind back to the tableView
the deselect action isn't being called. I have added the necessary deselect code to my viewWillAppear
so can't seem to work out what could be going wrong. Is there a different method for this use-case?
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
//Deselect row on unwind
if let path = folderTableView.indexPathForSelectedRow {
folderTableView.deselectRow(at: path, animated: true)
}
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print("Select")
switch indexPath.section {
case 2:
let cell = tableView.cellForRow(at: indexPath) as! FolderTagTableViewCell
cell.folderTagSelectionBKG.alpha = 1.0
default:
let cell = tableView.cellForRow(at: indexPath) as! FolderTableViewCell
cell.folderSelectionBKG.alpha = 1.0
}
}
func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
print("Should deselect")
switch indexPath.section {
case 2:
let cell = tableView.cellForRow(at: indexPath) as! FolderTagTableViewCell
UIView.animate(withDuration: 0.2, delay: 0.0, options: .curveEaseInOut, animations: {
cell.folderTagSelectionBKG.alpha = 0
})
default:
let cell = tableView.cellForRow(at: indexPath) as! FolderTableViewCell
UIView.animate(withDuration: 0.2, delay: 0.0, options: .curveEaseInOut, animations: {
cell.folderSelectionBKG.alpha = 0
})
}
}