[ListView] Fix RCTScrollView stickyHeader touch passing.

Summary:
Point must be converted to the stickyHeader's coordinate space and then passed to the stickyHeaders hitTest:withEvent: method in order to be correctly routed to any subviews of the stickyHeader.

This resolves this [issue](https://github.com/facebook/react-native/issues/2075).
Closes https://github.com/facebook/react-native/pull/2224
Github Author: Tj <tfallon@Tjs-MBP.local>
This commit is contained in:
Tj 2015-08-04 16:54:09 -07:00
parent f165bbaf4e
commit d8f43105ed

View File

@ -339,20 +339,16 @@ RCT_NOT_IMPLEMENTED(-init)
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{ {
__block UIView *stickyHeader; __block UIView *hitView;
[_stickyHeaderIndices enumerateIndexesWithOptions:0 usingBlock:^(NSUInteger idx, BOOL *stop) { [_stickyHeaderIndices enumerateIndexesWithOptions:0 usingBlock:^(NSUInteger idx, BOOL *stop) {
stickyHeader = [self contentView].reactSubviews[idx]; UIView *stickyHeader = [self contentView].reactSubviews[idx];
CGPoint convertedPoint = [stickyHeader convertPoint:point fromView:self]; CGPoint convertedPoint = [stickyHeader convertPoint:point fromView:self];
hitView = [stickyHeader hitTest:convertedPoint withEvent:event];
if ([stickyHeader hitTest:convertedPoint withEvent:event]) { *stop = (hitView != nil);
*stop = YES;
} else {
stickyHeader = nil;
}
}]; }];
return stickyHeader ?: [super hitTest:point withEvent:event]; return hitView ?: [super hitTest:point withEvent:event];
} }
@end @end