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.
FIXED IT OUT !
My view was on a UIImageView, and that UIImageView hadn't the userInteractionEnabled
set to YES.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With