UIPinchGestureRecognizer's touch locations

2019-07-24 01:11发布

问题:

I want to implement zooming with pinch gesture in my iphone app. The problem is, in a method that gets called when the gesture is recognized I don't have access to the touch events themselves (so I can't really get their locationInView:) and I would like to get it in order to center my zoom-in properly.

In the UIPinchGestureRecognizer class definition there is a UITouch *_touches[2]; defined, but I can't access it from outside of the class. Is there anything I can do in order to get that data?

回答1:

Hope this helps UIPinchGestureRecognizer position the pinched view between the two fingers



回答2:

i did not find an easier way to do it:

You can create a custom UIPinchGestureRecognizer and have two properties for UITouches. Assign their values on touchesBegun and touchesMoved. Then just access those properties to find positions of touches

That is what I've done and it worked well. Hope it helps.