检测 UITableView 的自定义单元格上的点击 [英] Detecting taps on Custom Cells of UITableView

查看:30
本文介绍了检测 UITableView 的自定义单元格上的点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个包含三个 UILabel 的自定义 UITableViewCell.UITableViewCell 使得 UILabel 完全覆盖单元格.

So i have a custom UITableViewCell which contains three UILabel. The UITableViewCell is such that the UILabel completely cover the cell.

现在我想检测用户何时点击单元格.问题是 UILabel 覆盖了单元格,我无法使用 UITableView 委托方法来检测单元格上的触摸.

Now i want to detect whenever user taps on the cell. Problem is as the UILabel cover the cell I cannot use UITableView delegate method for detecting touch on the cell.

我想过在 UILabel 上使用手势识别器,但后来我没有得到触摸单元格的索引.我也想过在单元格顶部放置一个透明按钮,但这里也存在同样的问题,我无法获取触摸单元格的索引.

I thoughout about using gesture recoginzers on the UILabel but then i don't get the index of the touched cell. I also thought about placing a transparent button on top of the cells but here there is also the same problem that i can't get the index of the touched cell.

任何人都可以指导我如何在 UILabel 覆盖单元格时使用 tableView didSelectRowAtIndexPath 检测点击.

Can anybody guide me with an approach on how can i accomplish detecting taps with tableView didSelectRowAtIndexPath when UILabel are covering the cell.

推荐答案

UILabel 隐藏您的单元格还是 UIImageView 隐藏它并不重要.它会自动检测tableView didSelectRowAtIndexPath.首先检查它你不会遇到任何问题.有没有先尝试详细实现tableview

It doesnt matter whether UILabel hide your cell or UIImageView hide it. It will automatically detects tableView didSelectRowAtIndexPath. Check it first you wont face any problems. Did you try to implement tableview in detail first

这篇关于检测 UITableView 的自定义单元格上的点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆