使用UITableViewRowAction
非常棒。
有件事让我烦恼,我想保留原始单元格 textLabel
的一部分,以便我亲爱的用户知道他们要删除的内容。
通过使用UITableViewRowAction
,它将单元格标签推出屏幕,(请参阅绿色的“我的文本?”)
有办法解决这个问题吗?
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let editAction = UITableViewRowAction(style: .destructive, title: "Edit") { (rowAction, indexPath) in
//TODO: edit the row at indexPath here
}
editAction.backgroundColor = .gray
let deleteAction = UITableViewRowAction(style: .normal, title: "Delete") { (rowAction, indexPath) in
//TODO: Delete the row at indexPath here
}
deleteAction.backgroundColor = .red
let sendAction = UITableViewRowAction(style: .normal, title: "More") { (rowAction, indexPath) in
//TODO: Delete the row at indexPath here
}
sendAction.backgroundColor = .darkGray
return [deleteAction,editAction,sendAction]
}
最佳答案
如果您希望 labelText 保持原样,则必须添加一个删除按钮,因为您无法更改它。
关于ios - UITableViewRowAction - 保留单元格的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46907700/