0

我正在实现一个标签左侧带有复选标记的 UITableView 和右侧带有按钮的自定义附件视图。在 didSelectRowAt(indexPath) 中选中和取消选中复选标记。AccessoriesView 的自定义按钮实现如下:

let button = UIButton(type: .custom)
button.setImage(UIImage(named: "arrow-right-light.png")?.maskWithColor(color: .white), for: .normal)
button.sizeToFit()
button.addTarget(self, action: #selector(buttonTest), for: .touchUpInside)
button.tag = indexPath.row
cell.accessoryView = button

但是,表格视图的右角有一小块区域(如下图所示)仍然响应 didSelectRowAt(indexPath)。

仍然响应 didSelectRowAt(indexPath) 的按钮和 tableView 边缘之间的区域

有没有人对我如何以编程方式将按钮捕捉到 tablewView 的 rightMargin 有任何建议?我希望用户能够在不选择复选标记的情况下从按钮到表格边缘点击该区域(如下图所示):

预期按钮选择区域

谢谢你。

4

0 回答 0