0
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{

    UITouch *touch = [[event touchesForView:self.view] anyObject];
    CGPoint point = [touch locationInView:self.view];

    basketView.center = CGPointMake(point.x, point.y);


}

我目前有这段代码可以让用户用手指移动图像。但是,如果我想在屏幕上添加多个可移动图像(比如我还希望能够移动 UIImages basketView2 和 basketView3),我将如何更改代码以实现这一点?

4

1 回答 1

1

你只需要修改你的代码如下

UITouch *touch = [[event touchesForView:self.view] anyObject];
CGPoint point = [touch locationInView:self.view];
UIImageView *currentView=(UIImageView *)touch.view;
currentView.center = CGPointMake(point.x, point.y);
于 2013-03-11T04:15:12.773 回答