如何在 iOS 上实现多点触控
我想实现多点触控,并且希望能从这里的杰出人士那里得到一些健全性检查。 :)
据我所知,我检测和跟踪多点触摸的策略将是使用 TouchBegan _Moved 和 _Ended 方法,并使用事件参数的 allTouches 方法来获取任何特定时间所有相关触摸的可见性。
我想我本质上会使用 previousLocationInView 作为将新事件中的触摸与当前活动触摸链接起来的一种方式,即,如果 x,y = 10,14 处有一个 touchBegan,那么我可以使用下一条消息中触摸的前一个位置来了解该新触摸与哪一个触摸相关,作为跟踪一根手指的连续运动等的一种方式。这有意义吗?如果确实有意义,是否有更好的方法?我无法保留 UITouch 或 UIEvent 指针作为识别触摸与先前触摸的方式,所以我不能走那条路。我能想到的就是通过它们 previouslocationInView 值将它们联系在一起(并知道哪些是“新”触摸)。
I'd like to implement multitouch, and I was hoping to get some sanity checks from the brilliant folks here. :)
From what I can tell, my strategy to detect and track multitouch is going to be to use the touchesBegan _Moved and _Ended methods and use the allTouches method of the event parameter to get visibility on all relevant touches at any particular time.
I was thinking I'd essentially use the previousLocationInView as a way of linking touches that come in with my new events with the currently active touches, i.e. if there is a touchBegan for one that is at x,y = 10,14, then I can use the previous location of a touch in the next message to know which one this new touch is tied to as a way of keeping track of one finger's continuous motion etc. Does this make sense? If it does make sense, is there a better way to do it? I cannot hold onto UITouch or UIEvent pointers as a way of identifying touches with previous touches, so I cannot go that route. All I can think to do is tie them together via their previouslocationInView value (and to know which are 'new' touches).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能想看看手势识别器。从苹果的文档来看,
请参阅 关于手势识别器的文章,特别是标题为“创建自定义手势识别器”的部分。您需要一个 Apple 开发人员中心帐户才能访问此帐户。
You might want to take a look at gesture recognizers. From Apple's docs,
See the article on Gesture Recognizers and specifically the section titled "Creating Custom Gesture Recognizers." You will need an Apple Developer Center account to access this.