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 alloc] initWithTarget:self action:@selector(handleTap:)];singleTap.cancelsTouchesInView = NO;[scrollView addGestureRecognizer:singleTap];
Swift 3.0
let singleTap = UITapGestureRecognizer(target: self, action: #selector(handleTap(_:))) singleTap.cancelsTouchesInView = false singleTap.numberOfTapsRequired = 1 scrollView.addGestureRecognizer(singleTap)
And the selector method be like.
@objc func handleTap(_ recognizer: UITapGestureRecognizer) { // Perform operation}
I think the reason is that User Interaction Enabled
is set to false
for UIImageView. You should set it to true to enable tapping in it