开发者

touchesMoved:withEvent

开发者 https://www.devze.com 2022-12-12 18:16 出处:网络
I got the coordinates of touchesBegan and touchesEnded. But in touchesMoved can I get all the coordinates of the touch from touchesBegan to开发者_Go百科 touchesEnded.

I got the coordinates of touchesBegan and touchesEnded. But in touchesMoved can I get all the coordinates of the touch from touchesBegan to开发者_Go百科 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 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
}
0

精彩评论

暂无评论...
验证码 换一张
取 消