首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >touchesMoved:withEvent

touchesMoved:withEvent
EN

Stack Overflow用户
提问于 2009-11-22 13:48:27
回答 1查看 3K关注 0票数 1

我得到了touchesBegan和touchesEnded的坐标。但在touchesMoved中,我能得到从touchesBegan到touchesEnded的所有触摸坐标吗?我的意思是,当我把手指放在屏幕上,拖到某个位置,然后我把它举起来。那么,我能得到从起始位置到结束位置的所有坐标吗?如果可能,我怎样才能得到它们?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2009-11-22 13:58:38

每当触摸上有移动时,就会调用TouchesMoved。如果想要一个包含所有点的数组,则需要在每次调用touchesMoved时将它们添加到一个可变数组中。

代码语言:javascript
复制
- (void) touchesMoved: (NSSet *)touches withEvent:(UIEvent *)event {
    CGPoint tappedPt = [[touches anyObject] locationInView: self];
    int     xPos = tappedPt.x;
    int     yPos = tappedPt.y;
    // do something with xPos and yPos like add them to an array
}
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1777940

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档