我附上了一个自定义 UIGestureRecognizer
到一个 UIView
几乎填满了整个屏幕。这个 View 包含一个小的 subview ,它也需要接收正常的触摸。
问题:在这个 subview 上开始的触摸不是由附加到其父 View 的识别器处理的。
我希望gestureRecognizer 是第一优先级并且即使 subview 被触摸也可以工作。我怎样才能将在这个 subview 上开始的所有触摸也转发给它的父 View ,以便我的gestureRecognizer 可以完成它的工作?
最佳答案
我找到了解决方案!其实很简单。
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
// Forward this message up the responder chain
[super touchesBegan:touches withEvent: event];
}
在
touchBegan
中对 super 的调用 subview 的全部内容。在这个博客上找到它
Allow superview to recieve events caught by subview
关于iphone - 使 UIGestureRecognizer 接收 subview 上开始的触摸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8772290/