Monday, 9 September 2013

Dragging UIImage only when your finger is on the UIImage

Dragging UIImage only when your finger is on the UIImage

I successfully coded an image which is draggable but, if you randomly
click somewhere in the screen it just teleports itself to that point. I
don't want that! How can I make the image only draggable when your finger
is on the image? This is the code I have:
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
symbol1.center = location;
}
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[self touchesBegan:touches withEvent:event];
}
Thanks in advance!

No comments:

Post a Comment