I have a stack of subtitles that have user interactive sections (children) and the whole full-screen mode. The problem is that if I touch the non-interactive section at the top of the stack, it will not extend that touch to the rest of the stack. My setup:
view A --view B (full-screen container, not interactive itself, but with interactive subtitles) ---- view B1 (interactive) ---- view B2 (interactive) --view C (same as B) - --- view C1 (interactive) ---- view C2 (interactive)
B and C are full-screen, but B1 / B2 / C1 / C2 are only small sections of the screen.
[a addSubview:b]
If I touch anything outside of C1 / C2, I would like the touch event to check if it got somewhere inside B (B1 / B2), but instead it goes back to A and then to the parent. do it? If I set userInteractionEnabled NO to C, but YES to C1 / C2, it will not receive any calls to internal either, although in this case B will receive the strokes as expected.
edit: manually moving the viewing stack to finish checking only certain sub-items, and not all of them:
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { if (self != self.topCustomViewsContainer) { for (UIView *v in self.createdSubviews) { CGPoint newPoint = point; newPoint.x -= v.frame.origin.x; newPoint.y -= v.frame.origin.y; UIView *hit = [v hitTest:newPoint withEvent:event]; if (hit) return hit; } return nil; } return [super hitTest:point withEvent:event]; }
puzzl source share