I have a UIImageView
in a view controller. Is it possible to make certain areas of the image view tappable?
Example : I have an image of a map. Make only the POIs tappable. Not the whole image. Is this possible?
You can use the handleGesture method. First you need to create a location to receive the touches and you have to compare it with touch location in the delegate method as below:
CGRect locationRect;
in viewdidload
locationRect = CGRectMake(CREATE A FRAME HERE);
next the delegate method
- (void)handleGesture:(UIGestureRecognizer *)gestureRecognizer {
CGPoint p = [gestureRecognizer locationInView:self.view];
if (CGRectContainsPoint(locationRect, p)) {
NSLog(@"it's inside");
} else {
NSLog(@"it's outside");
}
}