简体   繁体   English

如何区分用户点击我的表格视图单元格和用户点击该单元格中包含的子视图之间的区别?

[英]How do I tell the difference between the user tapping my table view cell and the user tapping a subview contained within the cell?

One of my view controllers contains a UITableView with custom UITableViewCell's. 我的一个视图控制器包含一个带有自定义UITableViewCell的UITableView。 My custom UITableView cell contains a UIImageView subview that represents a tappable icon. 我的自定义UITableView单元格包含一个UIImageView子视图,该子视图表示可轻击的图标。 When the user taps anywhere on the custom cell, except the icon subview, I want my didSelectRowAtIndexPath method to be called like normal. 当用户点击自定义单元格上除图标子视图之外的任何位置时,我都希望像通常一样调用didSelectRowAtIndexPath方法。 But when my icon subview gets tapped, I want a different method to get called, but I can't figure out how to do this. 但是,当我的图标子视图被点击时,我希望调用一种不同的方法,但是我不知道该怎么做。 Do I have capture the touch position in the touchesDidBegin method and manually check if the user tapped the icon? 我是否已在touchesDidBegin方法中捕获触摸位置并手动检查用户是否点击了图标? That just feels so hacky. 感觉太hacky了。 Other, cleaner ideas? 其他更清洁的想法?

Thanks so much for your wisdom! 非常感谢您的智慧!

只需将tapGestureRecognizer添加到单元格中的UIImageView

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 点击表格视图单元格 - tapping on table view cell 通过点击表格视图中的单元格来检查/取消选中该复选框,以及如何知道已选中或取消选中的单元格 - check / uncheck the check box by tapping the cell in table view and how to know which cell has checked or unchecked 如何通过点击表格视图单元格内的标签来显示另一个视图控制器 - How to present another view controller by tapping on a label inside a tableview cell 如何通过自定义单元格中以编程方式添加的UiImageViews推送新视图 - How to push a new view tapping programmatically added UiImageViews in a custom cell 点击UITableView单元格将创建一个新单元格 - Tapping a UITableView cell is creating a new cell 如果我将UISwitch控件添加到每个表视图单元格中,如何判断它属于哪个单元格? - If I add a UISwitch control to each of my table view cells, how can I tell which cell it belongs to? 如何通过再次点击所选按钮来取消选择多个UITableview单元格 - How to unselect multiple UITableview cell by tapping the selected button again 点击表格单元格时显示图片 - displaying pictures when tapping a tableview cell 如何克服点击表格中的一行 - How to overcome of tapping a row in a table 用户返回到表格视图时如何执行单元格取消选择? - How to perform a cell deselection when a user returns to a table view?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM