0

Im using GestureRecognizer delegate for pinch,pan,rotate,longpress for images. I used UIPinchGestureRecognizer delegate for pinching.

But, when i pinch zoomIn it doesn't have any problem. When i zoomOut certain level the images are small, and i can't ZoomIn pinching the images. After that, when i apply pan, the pan is applying whole view and only the image while i release my finger. After release my finger,the pan is apply only image. After touch the image pan apply on whole view

code:

 UIPinchGestureRecognizer *pinchGesture1 = [[UIPinchGestureRecognizer alloc]  initWithTarget:self action:@selector(ahandlePinch1:)];

 [myImageView addGestureRecognizer:pinchGesture1];

-(void)ahandlePinch1:(UIPinchGestureRecognizer*)sender {
    mCurrentScale += [sender scale] - mLastScale;
    mLastScale = [sender scale];

    if (sender.state == UIGestureRecognizerStateEnded)
    {
        mLastScale = 1.0;
    }

    CGAffineTransform currentTransform = CGAffineTransformIdentity;
    CGAffineTransform newTransform = CGAffineTransformScale(currentTransform, mCurrentScale, mCurrentScale);
    myImageView.transform = newTransform;
}
HRM
  • 2,097
  • 6
  • 23
  • 37
user2474320
  • 315
  • 1
  • 5
  • 17

1 Answers1

2

You should modify your ahandlePinch1 method so that you don't reduce the size of the image below a certain amount. It is almost certainly getting so small that it can no longer detect two distinct touches (which are required for the pinch gesture).

Apple generally recommend allowing a minimum of 44x44 pts as a touchable area, so I would suggest you stop your image from resizing below 88x88.

Alternatively, if you actually need your image to be less than that then you should add the gesture recognizer to a different view (perhaps the superview), rather than the image itself.

lxt
  • 31,146
  • 5
  • 78
  • 83
  • 1
    ...just add a conditional statement that doesn't apply the transform if your view is less than 88x88 in size. – lxt Jul 10 '13 at 10:24
  • This code is correct or not? if ( [recognizer scale] > 2 ) [recognizer view].transform = CGAffineTransformScale([[recognizer view] transform], [recognizer scale], – user2474320 Jul 10 '13 at 10:29