UIPanGestureRecognizer起点关闭 [英] UIPanGestureRecognizer starting point is off

查看:203
本文介绍了UIPanGestureRecognizer起点关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UIView,有一个UIPanGestureRecognizer连接到它的手势是工作正常,除了起点不是首先开始它的地方通常在x和y坐标5到15像素。不幸的是方差不一致,并且似乎与平移运动发生的速度有关。

I have a UIView that has a UIPanGestureRecognizer attached to it the gesture is working fine except that the starting point is not where the pan first started it is usually off by 5 to 15 pixels in both the x and y coordinates.Unfortunately the variance is not consistent and seems to be related to the speed at which the panning motion takes place.

为了验证触摸正确发送,我添加了一个touchesBegan方法到一个子视图,它接收正确的起点,但手势不提供相同的点在其开始阶段。

To validate that the touches are being sent correctly I have added a touchesBegan method to a subview and it receives the correct starting point but the gesture does not provide the same point in it's begin phase. Some examples from my logs are below 'Line start point' is the first point received from the gesture recognizer.

touchesBegan got point 617.000000x505.000000
Line start point at 630.000000x504.0000001
touchesBegan got point 403.000000x503.000000
Line start point at 413.000000x504.000000 
touchesBegan got point 323.000000x562.000000
Line start point at 341.000000x568.000000

以前有人看过此问题吗?

Has anyone seen this issue before?

有关如何解决这个问题的任何想法,无需实现一个全新的UIGestureRecognizer?

Any ideas on how to work around the issue with out having to implement an entirely new UIGestureRecognizer?

推荐答案

您可以使用手势识别器的委托方法检测手势的初始触摸位置

You can detect initial touch position of a gesture with the gesture recognizer's delegate method

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch

这篇关于UIPanGestureRecognizer起点关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆