本文介绍了UIScrollView子视图中的水平UISwipeGestureRecognizer? (UIScrollView只需要识别垂直滚动)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个UIScrollView,我添加了一个子视图。 scrollview垂直滚动,这就应该做。我现在想在UISwipeGestureRecognizer的帮助下识别子视图中的左/右滑动。我知道这是可能的,但是我没有遇到过解决方案而且有几次尝试都没有成功。
I have a UIScrollView where I added a subview. The scrollview scrolls fine vertically and that is all it should do. I would now like to recognize left/right swipes in the subview with the help of a UISwipeGestureRecognizer. I know it is possible, but I have not come across a solution and several tries have been unsuccessful.
推荐答案
试试这些:
-
设置
UIGestureRecognizer的代表
和
实施 shouldRecognizeSimultaneouslyWithGestureRecognizer
:
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
return YES;
}
实施 shouldReceiveTouch
:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
return YES;
}
希望这有助于
这篇关于UIScrollView子视图中的水平UISwipeGestureRecognizer? (UIScrollView只需要识别垂直滚动)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!