如何获取多点触控 UITapGestureRecognizer 的多个位置 [英] How to get multiple locations of multi touch UITapGestureRecognizer

查看:41
本文介绍了如何获取多点触控 UITapGestureRecognizer 的多个位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我看来,我有一个 UITapGestureRecognizer,我可以用下面的代码很好地获得它的接触位置.现在,如果我将此识别器的触摸次数更改为 2(或更多),它仍然会给我一个位置.如何获得两次触摸的两个位置?

I have a UITapGestureRecognizer in my view and I can get the location of its touch with below code fine. Now if I change this recognizer's number of touches to 2 (or more), it still gives me one location. How can I get two locations of the two touches?

tapGesture.locationInView(self.view)

请尽快帮助.

推荐答案

不使用 locationInView,而是使用 locationOfTouch 来获取每次点击的位置:

Instead of using locationInView, use locationOfTouch to get the location of each tap:

let tapLocation1 = tapGesture.locationOfTouch(0, inView: self.view)
let tapLocation2 = tapGesture.locationOfTouch(1, inView: self.view)

这篇关于如何获取多点触控 UITapGestureRecognizer 的多个位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆