问题描述
我得到了touchesBegan和touchesEnded的坐标。
但是在touchesMoved中,我可以获取从touchesBegan到touchesEnded的所有触摸坐标。
我的意思是当我将手指放在屏幕上并拖动到某个位置然后抬起它时。
因此,我可以获取开始位置到结束位置的所有坐标。
如果可能,我如何获得它们?
I got the coordinates of touchesBegan and touchesEnded.But in touchesMoved can I get all the coordinates of the touch from touchesBegan to touchesEnded.I mean that when I put finger on screen and dragged to some position and then I lifted it.So, can I get all the coordinates of the starting position to end position.If possible, how I can I get them ?
推荐答案
TouchesMoved会在触摸发生移动时被调用。如果需要所有点的数组,则每次调用touchesMoved时都需要将它们添加到可变数组中。
TouchesMoved gets called whenever there is movement on the touch. If you want an array of all points you'll need to add them to a mutable array every time touchesMoved is called.
- (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
}
这篇关于touchesMoved:withEvent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!