ScrollView gesture recognizer eating all touch events

前端 未结 9 787
北恋
北恋 2020-11-27 03:45

I have a UIScrollView to which I added a single tap gesture recognizer to show/hide some UI overlay using:

UITapGestureRecognizer *singleTap = [         


        
9条回答
  •  南方客
    南方客 (楼主)
    2020-11-27 04:08

    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]; 
    

提交回复
热议问题