我有,我增加了一个子视图一个UIScrollView。 滚动视图滚动精细垂直,这是所有它应该做的。 我现在想认识与UISwipeGestureRecognizer的帮助下,子视图左/右刷卡。 我知道这是可能的,但我还没有碰到过一个解决方案,并多次尝试均告失败。
Answer 1:
试试这些:
设置您的委托
UIGestureRecognizer
和实施
shouldRecognizeSimultaneouslyWithGestureRecognizer
:-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{ return YES; }
实施
shouldReceiveTouch
:- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { return YES; }
希望这可以帮助
Answer 2:
我能够完成与新的iOS 7 UIGestureRecognizerDelegate方法相关的东西(直接在滚动视图加入了双指滑动手势识别):
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return otherGestureRecognizer == scrollView.panGestureRecognizer;
}
然而,结果并不完美 - 延迟等待轻扫手势识别失败首先使滞后于滚动型的泛手势识别获取其接触,所以当你开始滚动正常滚动明显延迟。
文章来源: Horizontal UISwipeGestureRecognizer in subview of UIScrollView ? (UIScrollView only needs to recognize vertical scrolling)