How to pass a 'tap' to UIButton that is underneath UIView with UISwipeGestureRecognizer?

后端 未结 4 1926
伪装坚强ぢ
伪装坚强ぢ 2021-02-07 13:09

I have a UIButton underneath a (transparent) UIView. The UIView above has a UISwipeGestureRecognizer added to it, and that is its only purpose - to detect certain swipe gestures

4条回答
  •  眼角桃花
    2021-02-07 13:31

    Have you set:

    mySwipeGesture.cancelsTouchesInView = NO;
    

    to allow the touches to be sent to the view hierarchy as well as the gesture?

    Additionally, ensure that the view on top is:

    theTransparentView.opaque = NO;
    theTransparentView.userInteractionEnabled = YES;
    

    I've had pretty good success attaching gestures to the parent view without needing to create a transparent subview on top for the gesture. Are you sure you need to do that?

提交回复
热议问题