UIPinchGestureRecognizer's touch locations

假如想象 提交于 2020-01-05 03:29:24

问题


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.



来源:https://stackoverflow.com/questions/5311197/uipinchgesturerecognizers-touch-locations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!