0

I had detected the two finger touch for imageview and given condition that if two finger is touched then pinchGesture have to perform the selector for imageview.

if ([[event allTouches]count] == 2)
    {
        imageView.multipleTouchEnabled=YES;
        imageView.userInteractionEnabled =YES;
        twoFingerPinch = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(twoFingerPinch:)];
    }

- (void)twoFingerPinch:(UIPinchGestureRecognizer *)recognizer
{
    CGFloat scale = recognizer.scale;
    imageView.transform = CGAffineTransformScale(imageView.transform, scale, scale);
    recognizer.scale = 1.0;
}

But my twoFingerPinch method is not called. Anybody help me!! Thanks in advance.

2 Answers2

0

As per your code it is hard to say on which view you want to apply pinch gesture,I am considering you are applying it on imageView, here is how you should do it:-

-(void)viewDidLoad
{
UIPinchGestureRecognizer * pinch = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(twoFingerPinch:)];
[imageView addGestureRecognizer:pinch];
[imageView setUserInteractionEnabled:YES];
pinch.delegate = self;
}

- (void)twoFingerPinch:(UIPinchGestureRecognizer *)recognizer
{
    CGFloat scale = recognizer.scale;
    imageView.transform = CGAffineTransformScale(imageView.transform, scale, scale);
    recognizer.scale = 1.0;
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
 return NO;  

}
Vizllx
  • 9,135
  • 1
  • 41
  • 79
0

Don't sure what are you trying to do, but if you want to pinch just add that directly to the view. Its default behavior for pinch to use 2 fingers.

sarunw
  • 8,036
  • 11
  • 48
  • 84