0
我試圖改變UITableViewRowAction的標題,每次用戶按下它就像完成/不完整,我寫的代碼把複選標記,但不改變標題,所以複選標記不能被刪除:更改UITableViewRowAction swift的標題3
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let completeAction = UITableViewRowAction(style: .normal, title: "Complete", handler: { (action, indexPath) in
if action.title == "Complete"{
action.title = "Incomplete"
cell?.accessoryType = UITableViewCellAccessoryType.checkmark
}
else{
cell?.accessoryType = UITableViewCellAccessoryType.none
action.title = "Complete"
}
tableView.setEditing(false, animated: true)
})
completeAction.backgroundColor = .blue
return [completeAction]
}
有什麼建議?