[英]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.