[英]UITableViewRowAction - keeping the cell's text
Using UITableViewRowAction
is great. 使用
UITableViewRowAction
很棒。 One thing that bugs me, I would like to keep part of the original cell textLabel
so that my dear users will know what they are deleting. 让我
textLabel
一件事是,我想保留部分原始单元格textLabel
以便我亲爱的用户知道他们要删除的内容。
By using UITableViewRowAction
it pushes the cell label out of the screen, (see "MY TEXT?" in green) 通过使用
UITableViewRowAction
它将单元格标签推出屏幕,(请参见绿色的“我的文本?”)
Any way around this? 可以解决吗?
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保持原样,则必须添加一个删除按钮,因为您无法更改此按钮。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.