Reputation: 16256
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.
Upvotes: 0
Views: 724
Reputation: 163228
Your UITapGestureRecognizer
's target should be self
and not the UIImageView
itself.
Upvotes: 4