How to pass the touch event to superview when userInteractionEnabled = YES?
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];
}
}
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;
}
}
You can use another UIView to "hide" the subview.
*Details : This UIView is the subview's sibling . it has the same size and position of your subview with background color of clear color.
*Explain: The new UIView will take the touch, and automatically pass it to the superview.
This way doesn't need to subclass your subview - it's a storyboard solution.
Please try this. Have fun!