I'm creating a program that allows swiping of a row to colour it in.
I have the below function for handling this.
func tableView(_ tableView: UITableView, editActionsForRowAt: IndexPath) -> [UITableViewRowAction]? {
if multipleActive
{
let select = UITableViewRowAction(style: .normal, title: "Received") { action, index in
print("Row Selected")
let cell = tableView.cellForRow(at: index)
let rowInt : Int = index.row
cell?.backgroundColor = .green
}
select.backgroundColor = .green
let deselect = UITableViewRowAction(style: .normal, title: "Deselect") { action, index in
print("Unpicked")
let cell = tableView.cellForRow(at: index)
let rowInt : Int = index.row
cell?.backgroundColor = .none
}
deselect.backgroundColor = .blue
return [select, deselect]
}
else {
return nil
}
}
However, I have a cancel button and on cancel I want the rows in the table to have the colouring set back to white. Is there a function that exists already for this?
Also I can swipe the rows and when multipleActive
is set to false it will show the delete button. I don't want swiping to be possible if multipleActive
is not true.