You're talking about 2 different things:
- The position of the touch that is triggering the pan gesture
recognizer locationInView
- The position of the view (you don't say if you're using the frame origin or the center)
It isn't clear what you're trying to do but you need to decide, are you moving the target view by the pan gesture translation:
if (recognizer.state == UIGestureRecognizerStateBegan) {
startLocation = targetView.center;
}
CGPoint translation = [recognizer translationInView:self.view];
CGPoint newCenter = startLocation;
newCenter.x += translation.x;
newCenter.y += translation.y;
targetView.center = newCenter;
or you're trying to snap the target view to the pan gesture location
targetView.center = [recognizer locationInView:self.view];
This is all assuming that the target view is a direct subview of self.view...