我正在尝试更改UITableViewRowAction的标题,每次用户按下它就像完成/不完整一样,我写的代码放置复选标记但不更改标题,因此无法删除复选标记:
var modal_html
有什么建议吗?
答案 0 :(得分:0)
这就是我解决它的方法:
var complete:Bool = false
{
didSet{
if complete {
comp = "Incomplete"
}
else{
comp = "Complete"
}
}
}
var comp:String = "Complete"
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let cell = tableView.cellForRow(at: indexPath)
let completeAction = UITableViewRowAction(style: .normal, title: "\(comp)", handler: { (action, indexPath) in
if action.title == "Complete"{
self.complete = true
cell?.accessoryType = UITableViewCellAccessoryType.checkmark
}
else{
self.complete = false
cell?.accessoryType = UITableViewCellAccessoryType.none
}
tableView.setEditing(false, animated: true)
})
completeAction.backgroundColor = .blue
return [completeAction]
}