Skip to content

Instantly share code, notes, and snippets.

@manmal
Created January 15, 2014 08:54
Show Gist options
  • Save manmal/8432920 to your computer and use it in GitHub Desktop.
Save manmal/8432920 to your computer and use it in GitHub Desktop.
Forwards hit testing on a UITableView to certain views which are behind the tableview (siblings of UITableView). Quite hacky :/ If you know a better way, please tweet @manuelmaly
@interface MMTableViewWithParallaxHeader : UITableView
@property (strong, nonatomic) NSArray *forwardTouchesOnTransparentCellToViews;
@end
@implementation MMTableViewWithParallaxHeader
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
if ([self pointInside:point withEvent:event]) {
for (UITableViewCell *cell in self.visibleCells) {
if ([cell isKindOfClass:MMTransparentCell.class] && [cell pointInside:[self convertPoint:point toView:cell] withEvent:nil]) {
for (UIView *forwardTouchesView in _forwardTouchesOnTransparentCellToViews) {
if ([forwardTouchesView hitTest:[self convertPoint:point toView:forwardTouchesView] withEvent:event])
return nil;
}
}
}
}
return [super hitTest:point withEvent:event];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment