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]
}
有什么建议?