本文介绍了模拟滚动视图中的拖动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

:)我正在进行拦截,并重新发送发送到滚动视图的手势.

:) I am working on intercepting, and resending gestures sent to a scrollview.

我想做什么:

杀死滚动视图中的所有gestureRecognizer.我已经做到了.

Kill all gestureRecognizers in the scrollview. I have accomplished this.

在滚动视图中添加新的手势识别器.我也已经做到了.

Add new gestureRecognizers in the scrollview. I have accomplished this as well.

使新识别器的行为与旧识别器相同.我尚未完成此操作,我需要帮助.

Make the new recognizers behave the same as the old ones. I have NOT accomplished this, and I need help doing so.

我添加的唯一新识别器是摇动手势识别器,它至少需要两个手指.我希望它的行为就像单指滚动一样. :)

The only new recognizer I have added is a pan gesture recognizer, which requires at least two fingers. I want this to behave exactly as a one finger scroll. :)

响应新识别器生成的回调时,我必须发送哪种呼叫?

What kind of calls must I send when responding to the callbacks generated by the new recognizer to accomplish this?

推荐答案

我认为您通过尝试实现自己的自定义手势识别器已经使这一过程变得过于复杂.

I think you've overcomplicated this by trying to implement your own custom gesture recogniser.

UIPanGestureRecognizer类具有minimumNumberOfTouches属性,您应该可以将其UIScrollView设置为2.

The UIPanGestureRecognizer class has a minimumNumberOfTouches property which you should be able to set to 2 for your UIScrollView.

要这样做,只需抓住您的视图手势识别器即可.

To do so just grab your views gesture recognisers...

myScrollView.gestureRecognizers;

遍历数组以找到平移手势...

Iterate over the array to find the pan gesture...

if ([gestureRecogniser isKindOfClass:[UIPanGestureRecognizer class]])

将您的poseRecogniser指针投射到更具体的类型...

Cast your gestureRecogniser pointer to the more specific type...

UIPanGestureRecognizer *panGestureRecogniser = (UIPanGestureRecognizer *)gestureRecogniser;

最后设置它的minimumNumberOfTouches属性...

And finally set its minimumNumberOfTouches property...

panGestureRecogniser.minimumNumberOfTouches = 2;

您可能要做的唯一另一件事就是为视图启用多点触摸-UIView具有应该设置为true的multipleTouchEnabled属性.

The only other thing you may have to do is enabled multitouch for your view - UIView has a multipleTouchEnabled property that should be set to true.

这篇关于模拟滚动视图中的拖动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 06:53