Passing through touches to UIViews underneath

The UIGestureRecognizer is a red herring I think. In the end to solve this I overrode the pointInside:withEvent: method of my UIView: – (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { BOOL pointInside = NO; if (CGRectContainsPoint(imageView.frame, point) || expanded) pointInside = YES; return pointInside; } This causes the view to trap all touches if you touch either the … Read more

UITapGestureRecognizer tap on self.view but ignore subviews

You should adopt the UIGestureRecognizerDelegate protocol inside the self object and call the below method for checking the view. Inside this method, check your view against touch.view and return the appropriate bool (Yes/No). Something like this: – (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { if ([touch.view isDescendantOfView:yourSubView]) { return NO; } return YES; } Edit: Please, also … Read more

How do I implement the UITapGestureRecognizer into my application

This is a step by step guide on how to implement gesture recognizers in your class: Conform your class to UIGestureRecognizerDelegate protocol. Instantiate the gesture recognizer. For example, to instantiate a UITapGestureRecognizer, we will do: UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapFrom:)]; Here, action is the selector which will handle the gesture. Here, our selector … Read more

ScrollView gesture recognizer eating all touch events

This should solve your problem. Detect touch event on UIScrollView AND on UIView’s components [which is placed inside UIScrollView] The idea is to tell the gesture recognizer to not swallow up the touch events. To do this you need to set singleTap’s cancelsTouchesInView property to NO, which is YES by default. UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer … Read more

UITapGestureRecognizer – single tap and double tap

UITapGestureRecognizer *singleTap = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doSingleTap)] autorelease]; singleTap.numberOfTapsRequired = 1; [self.view addGestureRecognizer:singleTap]; UITapGestureRecognizer *doubleTap = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doDoubleTap)] autorelease]; doubleTap.numberOfTapsRequired = 2; [self.view addGestureRecognizer:doubleTap]; [singleTap requireGestureRecognizerToFail:doubleTap]; Note: If you are using numberOfTouchesRequired it has to be .numberOfTouchesRequired = 1; For Swift let singleTapGesture = UITapGestureRecognizer(target: self, action: #selector(didPressPartButton)) singleTapGesture.numberOfTapsRequired = 1 view.addGestureRecognizer(singleTapGesture) let … Read more

How to tap to zoom and double tap to zoom out in iOS?

You need to implement UITapGestureRecognizer – docs here – in your viewController – (void)viewDidLoad { [super viewDidLoad]; // what object is going to handle the gesture when it gets recognised ? // the argument for tap is the gesture that caused this message to be sent UITapGestureRecognizer *tapOnce = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapOnce:)]; UITapGestureRecognizer *tapTwice … Read more