UIPinchGestureRecognizer 的触摸位置
我想在我的 iPhone 应用程序中使用捏合手势实现缩放。问题是,在识别手势时调用的方法中,我无权访问触摸事件本身(因此我无法真正获取它们的 locationInView:
),并且我想获取它以便我的放大正确居中。
在 UIPinchGestureRecognizer
类定义中有一个 UITouch *_touches[2];
已定义,但我无法从类外部访问它。我可以做些什么来获取这些数据吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我没有找到更简单的方法:
您可以创建一个自定义 UIPinchGestureRecognizer 并为 UITouches 有两个属性。在touchesBegun 和touchesMoved 上分配它们的值。然后只需访问这些属性即可找到触摸的位置
这就是我所做的并且效果很好。希望有帮助。
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.
希望这有助于 UIPinchGestureRecognizer 将捏合视图定位在两根手指之间
Hope this helps UIPinchGestureRecognizer position the pinched view between the two fingers