sri*_*ali 1 iphone cocoa-touch objective-c
我得到了touchesBegan和touchesEnded的坐标.但是在touchesMoved中我可以获得从touchesBegan到touchesEnded的所有触摸坐标.我的意思是当我把手指放在屏幕上并拖到某个位置然后我举起它.那么,我可以得到起始位置的所有坐标到终点位置.如果可能的话,我怎么能得到它们?
只要触摸有移动,就会调用TouchesMoved.如果你想要一个所有点的数组,每次调用touchesMoved时你都需要将它们添加到一个可变数组中.
- (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
}
Run Code Online (Sandbox Code Playgroud)