I am using touchesBegan:
.
I touch an object and drag-and-drop it to some other place, but I also want to make a copy of it on its original. That is, after touching and dragging, there should be a copy of it at its original position.
Below is my code:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch=[[event allTouches]anyObject];
CGPoint location=[开发者_如何学编程touch locationInView:touch.view];
image1.center=location;
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
[self touchesBegan:touches withEvent:event];
}
Instead of moving image1 create and image2 (in touchesBegan
) and move it (in touchesMoved
)
You have to get touches from the superview of the object you want to move I believe.
You didn't show what image1 is, hence nobody can tell certainly how to copy that.
精彩评论