Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITapGestureRecognizer doesn't fire up on UIView Subclass

I've created a custom subclass of UIView because I needed to override drawRect method. I try to add a UITapGestureRecognizer to it, but this doesn't work for me. Here, the code of my ViewController:

MyCustomView *customView = [[MyCustomView alloc] initWithFrame:CGRectFrame(0, 30, 30, 30)];
[customView setUserInteractionEnabled:YES];

UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doSomething)];
[customView addGestureRecognizer:tapGestureRecognizer];

I don't understand why when I touch my UIView subclass object, the gesture recognizer doesn't fire up.

Thanks a lot in advance !

FIXED IT OUT !

My view was on a UIImageView, and that UIImageView hadn't the userInteractionEnabled set to YES.

like image 241
Vinestro Avatar asked Jun 11 '12 11:06

Vinestro


1 Answers

FIXED IT OUT !

My view was on a UIImageView, and that UIImageView hadn't the userInteractionEnabled set to YES.

like image 193
Vinestro Avatar answered Sep 22 '22 22:09

Vinestro