ios - 如何在 UITableViewCell 中创建信息按钮?

标签 ios swift xcode uitableview

每当我单击编辑按钮时,如何在右侧创建用于编辑内容的信息按钮以及删除控件(左侧)?

image

(类似这样)

`

override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
    if editingStyle == .delete {
        objects.remove(at: indexPath.row)
        tableView.deleteRows(at: [indexPath], with: .fade)
    } else if editingStyle == .insert {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
    }
}`

最佳答案

使用附件类型。

在cellForRowAt方法中,添加

    cell.editingAccessoryType = .detailButton

并通过以下方式对其采取行动

   override func tableView(_ tableView: UITableView, accessoryButtonTappedForRowWith indexPath: IndexPath) {
        print("Accessory btn tapped")
    }

关于ios - 如何在 UITableViewCell 中创建信息按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49962898/

相关文章:

ios - 执行异步任务

ios - iPad 中 iFrame 中的 Extjs Web 应用程序链接没有响应

objective-c - 如何在 1 个单元格中放置 3 个图像

ios - UIAlert 突然停止工作?

ios - 有谁知道为什么 else 代码部分不能隐藏我的 colorPicker?

ios - 是否可以通过 Xcode(连接到调试器)检测 iPhone 应用程序何时启动?

xcode - 布局中的奇怪异常

ios - 自动布局在自定义 TableViewCell 中被忽略

正则表达式查找 = 符号未被空格包围并替换为空格

ios - 双Segue IOS