How to pass the touch event to superview when userInteractionEnabled = YES?

后端 未结 6 1117
青春惊慌失措
青春惊慌失措 2020-12-17 14:24

I have the following setup.

+- XXXCustomControl : UIControl -------+
| A                                    |
|   +- ContentView -------------------+|
|   |         


        
6条回答
  •  天命终不由人
    2020-12-17 14:54

    You could try overriding the pointInside:withEvent: method in your inner view. This will allow you to return NO when you want to forward touches to the superview:

    -(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
    {
        if( /* You have content, and you want to receive touches */){
            return YES;
        }else{
            return NO;
        }
    }
    

提交回复
热议问题