简体   繁体   中英

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.
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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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