I have this code to drag an imageView:
in touchbegan:
CGPoint point = [touch locationInView:self];
[imageView setCenter:point];
in touchmoved:
CGPoint point = [touch locationInView:self];
[imageView setCenter:point];
this code allow to have imageview ever under my finger and move it form its center.
But I want something that allow me drag an imageview not only from center of imageview but also from another point of imageview…and not drag it if I touch out of this imageView… can you help me?
Instead of just setting the center point to the touch point you need to work out how the touch has moved.
Store the touch point in a variable.
In touchesBegan…
Then in touchesMoved…
Something like this anyway.
To ignore the touch you could say in touchesBegan…
(trackTouches is a class var)
Then in touchesMoved only do stuff if trackTouches == YES.