ios - UITableViewRowAction - 保留单元格的文本

标签 ios swift uitableview

使用UITableViewRowAction非常棒。 有件事让我烦恼,我想保留原始单元格 textLabel 的一部分,以便我亲爱的用户知道他们要删除的内容。

通过使用UITableViewRowAction,它将单元格标签推出屏幕,(请参阅绿色的“我的文本?”)

有办法解决这个问题吗?

enter image description here

 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/

相关文章:

ios - 奇怪的 UIScrollView 行为

java - Maven:在 POM 不可解析的父级上出现错误

android - 电晕 SDK : add velocity to non physics objects

swift - 如何将约束转换为 Item 或 Item 从 viewA 到 viewB?我收到此错误 : Unknown layout attribute

快速展开多个可选

ios - 带有图像、Swift 3 和核心数据的自定义单元格的缓慢 Tableview

ios - 如何在 iOS 应用程序中编辑 'projectile' 的速度

arrays - 将 String 转换为 Double 并检查是否为 nil

ios 6 UITableViewCell 删除按钮有背景色

ios - UITableView 中不可见的标签文本