简体   繁体   English

如何使用UIPanGestureRecognizer的_firstScreenLocation?

[英]How to use _firstScreenLocation of UIPanGestureRecognizer?

Hi I am using pinch zooming in a view. 嗨,我在视图中使用捏缩放。
I want to limit the distance of drag of this zoomed view. 我想限制此缩放视图的拖动距离。
Because zoomed view can be dragged till bottom or any other edges of the screen such that only background is visible and the actual view gets hidden behind,and there is no way to drag that view to center again. 因为可以将缩放的视图拖动到屏幕的底部或任何其他边缘,以使得仅背景可见并且实际视图隐藏在后面,所以无法将视图再次拖动到中心。
There is a variable called _firstScreenLocation and _lastScreenLocation which can be used to calculate the distance, but both the variables are inaccessible as they are declared under @package directive. 有一个名为_firstScreenLocation和_lastScreenLocation的变量可用于计算距离,但是这两个变量都是不可访问的,因为它们是在@package指令下声明的。
Please suggest some smarter way for doing this. 请提出一些更聪明的方法。

To find the distance moved capture the begin and current event then do the math: 要找到移动的距离,请捕获开始事件和当前事件,然后进行数学计算:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM