I have an image inside a UIImageView, which has a gesture for zooming, as you can see from the code.
I want to be able to insert clickable areas of the image, not the screen, so if I click an image point with minimum or maximum zoom zoom I always return the same value.
I could tell by the UIGestureRecognizer if I can do? Why can not I figure out whether I work or not.
thanks
My code:
UITapGestureRecognizer *twoFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTwoFingerTap:)];
[twoFingerTap setNumberOfTouchesRequired:2];
[img addGestureRecognizer:twoFingerTap];
float minimumScale = 0.4;//This is the minimum scale, set it to whatever you want. 1.0 = default
scroll.maximumZoomScale = 4.0;
scroll.minimumZoomScale = minimumScale;
scroll.zoomScale = minimumScale;
[scroll setContentMode:UIViewContentModeScaleAspectFit];
[img sizeToFit];
[scroll setContentSize:CGSizeMake(img.frame.size.width, img.frame.size.height)];
[control setSelectedSegmentIndex:0];
[control addTarget:self
action:@selector(action:)
forControlEvents:UIControlEventValueChanged];
//THIS IS MY RECOGNIZER ON IMAGE
UIGestureRecognizer *recognizerImage = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImage:)];
[(UITapGestureRecognizer *)recognizer setNumberOfTapsRequired:2];
[img addGestureRecognizer:recognizer];
}
- (void)tapImage:(UITapGestureRecognizer *)recognizer {
CGPoint location = [recognizer locationInView:self.view];
NSLog(@"x %f y %f",location.x, location.y);
}