gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 06:00:31 24 4
gpt4 key购买 nike

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

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.
}
}`

最佳答案

使用 accessoryType。

在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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com