在UIView和UITableView中冲突的UITapGestureRecognizer [英] Conflicting UITapGestureRecognizer in UIView and for UITableView
问题描述
我有 UIView
,其中我添加了 UITapGestureRecognizer
。在该视图中我还有一个子视图,其中基本上是某种 UITableView
。问题是为什么 UITableView
不识别行上的点击,而是一直进入点击手势识别器的处理程序。这是为什么,我该如何解决这个问题?如果我将点击数设置为2,那么它可以正常工作。关于如何解决这个问题的任何想法?基本上它不会调用 didSelectRowAtIndexPath
。
I have a UIView
in which I added a UITapGestureRecognizer
. Inside that view I also have a subview in which is basically some kind of a UITableView
. The question is that why doesn't the UITableView
recognizes the tap on a row, instead it goes to the tap gesture recognizer's handler all the time. Why is this, and how do I solve this? If I set the number of taps to 2, then it works fine. Any idea on how to solve this? Basically it doesn't call the didSelectRowAtIndexPath
.
推荐答案
设置您的识别器的cancelsTouchesInView
到否
。否则,它会消耗自己的触摸,并且不会将其传递到表格视图。这就是选择事件永远不会发生的原因。
Set cancelsTouchesInView
of your recognizer to NO
. Otherwise, it "consumes" the touch for itself, and does not pass it on to the table view. That's why the selection event never happens.
这篇关于在UIView和UITableView中冲突的UITapGestureRecognizer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!