次のコードを使用して複数のオブジェクトをドラッグしているときに、オブジェクトに触れるとオブジェクトが揺れます。
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
if ([touch view] == img1)
{
CGPoint location = [touch locationInView:touch.view];
img1.center = location;
return;
}
if (touch.view == img2)
{
CGPoint location = [touch locationInView:touch.view];
img2.center = location;
return;
}
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[self touchesBegan:touches withEvent:event];
}
私のコードの問題は何ですか?ドラッグする他の方法はありますか?ビューにもう1つのオブジェクトが含まれている場合は?この問題を解決するのを手伝ってください