Skip to content

Instantly share code, notes, and snippets.

@stigi
Created May 11, 2011 11:11
Show Gist options
  • Save stigi/966295 to your computer and use it in GitHub Desktop.
Save stigi/966295 to your computer and use it in GitHub Desktop.
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
// never return self. always return the result of [super hitTest..].
// this takes userInteraction state, enabled, alpha values etc. into account
UIView *hitResult = [super hitTest:point withEvent:event];
// don't check for links if the event was handled by one of the subviews
if (hitResult != self) {
return hitResult;
}
BOOL didHitLink = ([self linkAtPoint:point] != nil);
if (self.onlyCatchTouchesOnLinks && !didHitLink) {
return nil; // not catch the touch if it didn't hit a link
}
return hitResult;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment