UIScrollView覆盖我的子视图的平移手势识别器 [英] UIScrollView overrides my subview's pan gesture recognizers
本文介绍了UIScrollView覆盖我的子视图的平移手势识别器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有一个带有子视图的scrollView,子视图有一个平移手势识别器,scrollView的平移手势覆盖子视图的平移。我想要的是相反的,我想,所以这是我拖动一个子视图,它将滚动在滚动视图,但如果我触摸另一个区域,滚动视图将平移正常。
If I have a scrollView with a subview and the subview has a pan gesture recognizer, the scrollView's pan gesture override's the subview's pan. What I want is the opposite, I think, so that is I drag a subview it will pan within the scroll view, yet if I touch another area the scroll view will pan as normal. Is there an easy way to set that up?
推荐答案
以下是对我有用的方法:
Here's what works for me:
UIPanGestureRecognizer *subviewPanRecognizer = [[UIPanGestureRecognizer alloc]
initWithTarget:self action:@selector(panSubview:)];
[subview addGestureRecognizer:subviewPanRecognizer];
// play nice with subview's pan gesture
[scrollView.panGestureRecognizer
requireGestureRecognizerToFail:subviewPanRecognizer];
这篇关于UIScrollView覆盖我的子视图的平移手势识别器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文