I want to bind the tap event on a UIImageView like this:
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self.backgroundImage action:@selector(imageClicked:)];
[self.backgroundImage addGestureRecognizer:tap];
self.backgroundImage.userInteractionEnabled=YES;
And the method is there:
-(void)imageClicked:(id)sender{
NSLog(@"image clicked");
}
But when i click on the image view, my app crash and i got this stack:
[UIImageView imageClicked:]: unrecognized selector sent to instance
Am i missing something? Thanx in advance.
Your
UITapGestureRecognizer‘s target should beselfand not theUIImageViewitself.