我对触摸事件还很陌生,但我遇到了问题。我使用上面的代码在屏幕上拖动两个图像。但是,当第二根手指触摸屏幕时,代码会起作用,第一个动作就会停止。因此,问题与多点触控有关。我也是,不知道如何计算第二个触摸坐标。我在视图和两个图像中都启用了多点触控。如果有人可以帮助我用每根手指移动每张图像,我会非常满意。提前致谢!
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:self.view];
if ([touch view] == image) {
image.center = location;
} else if ([touch view] == image2) {
image2.center = location;
}}
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[self touchesBegan:touches withEvent:event];}