swift - 在没有 UIButton 的情况下单击时 UITableViewCell 不起作用
问题描述
单击时我正在工作 tableviewcell。当我单击单元格时它不起作用,我不想使用 UIButton 因为高度搞砸了。这是我的代码
cell.accessibilityIdentifier = "\(indexPath.section)"
cell.tag = indexPath.row
cell.target(forAction: #selector(reminderClicked), withSender: self)
和
@objc func reminderClicked(_ sender: UITableViewCell) {
print("\(sender.tag) - \(String(describing: Int(sender.accessibilityIdentifier ?? "0")))")
}
任何想法?
解决方案
有一个 TableViewDelegate 函数可用于检查单元格上的点击。
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {}
推荐阅读
- python - 无法使用 python 在 selenium 中捕获具有 _ngcontent-c6 的 Web 元素
- spring-boot - JPA。双向关联:ManyToOne。删除父级时如何删除关联?
- math - 从原点旋转的坐标系确定四元数(给出三个新的单位向量)
- node.js - 为什么在上传到 nosub 时会出现来自节点的未处理的承诺拒绝警告?
- python - 如何为列表设置限制?Python
- vulkan - 如何从 Vulkan 着色器中访问计时器?
- javascript - 如何使用 VB.NET 和 AJAX 调用 .NET 页面方法
- html - 如何更改 dropcap 的选择颜色?
- python - 如何获取所需的数据帧作为 groupby 的输出和 pandas 中的值计数
- unity3d - 粒子系统的位置未附加到对象