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

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

I have the following setup.

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


        
6条回答
  •  时光取名叫无心
    2020-12-17 14:57

    You can subclass your subview, and implement

    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
        if (!touchedContent) {
            [[self nextResponder] touchesBegan:touches withEvent:event];
        } else {
            [super touchesBegan:touches withEvent:event];
        }
    }
    

提交回复
热议问题