Key idea : You can add UITapGestureRecognizer
to UIImageView
. Setting up a selector
which will be fired for each tap. In the selector
you can check for the co-ordinate where the tap was done. If the co-ordinate satisfy your condition for firing up an event, you can execute your task then.
Adding the gesture recognizer:
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleImgViewTap:)];
[singleTap setNumberOfTapsRequired:1];
[yourImgView addGestureRecognizer:singleTap];
Setting up the selector:
-(void)handleImgViewTap:(UITapGestureRecognizer *)gestureRecognizer
{
// this method gonna fire everytime you tap on the
// image view. you have to check does the point where
// the tap was done, satisfy your path/area condition.
CGPoint point = [gestureRecognizer locationInView:yourImgView];
// here point.x and point.y is the location of the tap
// inside your image view.
if(/*your condition goes here*/)
{
// execute your staff here.
}
}
Hope it helps, Happy ios coding.