简体   繁体   English

UITableViewRowAction-保留单元格的文本

[英]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.

相关问题 更改UITableViewRowAction内部的单元格背景颜色 - change cell background color inside of UITableViewRowAction 具有角半径的UITableViewRowAction单元格更改背景色 - UITableViewRowAction Cell with Corner Radius Changes Background Color UITableViewRowAction 标题作为图像图标而不是文本 - UITableViewRowAction title as image icon instead of text 当单元格已显示两个时,再添加一个UITableViewRowAction - Add one more UITableViewRowAction when cell already shows two 在EditActionsForRow中返回UITableViewRowAction的空数组会中断在表格单元格上的滑动 - Returning an empty array of UITableViewRowAction in EditActionsForRow breaks swiping on a table cell 使用NSUserDefaults保持UITableView选定单元格的UIAccessoryType - Persistently keeping a UITableView selected cell's UIAccessoryType with NSUserDefaults UITableViewRowAction和UIAlertController - UITableViewRowAction and UIAlertController 关闭UITableViewRowAction - Dismiss UITableViewRowAction 当我实现UITableViewRowAction时,为什么所有Section Heading行都与表格单元格一起滑动 - Why do all Section Heading rows slide with table cell when i implement UITableViewRowAction 当向左滑动表格视图单元格到手机的左边缘时,它将自动触发删除UITableViewRowAction,如何禁用此功能? - when left swipe a tableview cell to the left edge of the phone, it will auto trigger the delete UITableViewRowAction , how to disable this?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM