0

Hi Guys I am trying to move UIImageView using the following code on UIPanGestureRecognizer

 CGPoint pointMove;
 pointMove.x = holderView.center.x + (currentPoint.x - lastPoint.x);
 pointMove.y = holderView.center.y + (currentPoint.y - lastPoint.y);

 holderView.center = pointMove;

 lastPoint = currentPoint;

But this is giving a jumble on moving not moving smoothly. Please help me

Shashank Kulshrestha
  • 1,556
  • 17
  • 31

2 Answers2

2

i got a best example of Dragging Image using UIPanGestureRecognizer

please download this demo and check it :-

https://github.com/elc/iCodeBlogDemoPhotoBoard

hope it's help's you

here are some same Asked Question please visit link:-

Drag + Rotation using UIPanGestureRecognizer touch getting off track

swapping images using pan gesture

How to use UIPanGestureRecognizer to move object? iPhone/iPad

Community
  • 1
  • 1
Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144
1

Try to change this in your code.

  CGPoint translation = [gestureRecognizer translationInView:[holderView superview]];

    [holderView setCenter:CGPointMake([piece center].x + translation.x, [piece center].y + translation.y)];

I hope this will solve your problem

prairiedogg
  • 6,323
  • 8
  • 44
  • 52
Satish Azad
  • 2,302
  • 1
  • 16
  • 35