开发者

iphone touchesbegan

开发者 https://www.devze.com 2023-01-28 09:01 出处:网络
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 co

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.

0

精彩评论

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