Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ - (void)bindToView:(UIView *)view
[control addTarget:self action:@selector(handleDragExit:forEvent:) forControlEvents:UIControlEventTouchDragExit];
[control addTarget:self action:@selector(handleDragEnter:forEvent:) forControlEvents:UIControlEventTouchDragEnter];
[control addTarget:self action:@selector(handleTouchCancel:forEvent:) forControlEvents:UIControlEventTouchCancel];

if (self.actionType == RNGestureHandlerActionTypeNativeDetector) {
[view addGestureRecognizer:_recognizer];
}

} else {
[super bindToView:view];
}
Expand Down
12 changes: 8 additions & 4 deletions packages/react-native-gesture-handler/apple/RNGestureHandler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,14 @@ - (void)sendEventsInState:(RNGestureHandlerState)state

- (RNGHUIView *)findViewForEvents
{
return
[self isKindOfClass:[RNNativeViewGestureHandler class]] && _actionType == RNGestureHandlerActionTypeNativeDetector
? self.recognizer.view.superview
: self.recognizer.view;
if ([self isKindOfClass:[RNNativeViewGestureHandler class]] &&
_actionType == RNGestureHandlerActionTypeNativeDetector) {
RNGHUIView *view = self.recognizer.view.superview;

return [view isKindOfClass:[RCTViewComponentView class]] ? view.superview : view;
}

return self.recognizer.view;
}

- (void)sendEvent:(RNGestureHandlerStateChange *)event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#import <React/RCTConversions.h>
#import <React/RCTFabricComponentsPlugins.h>

#import "RNGestureHandlerButtonComponentView.h"

#import <react/renderer/components/rngesturehandler_codegen/EventEmitters.h>
#import <react/renderer/components/rngesturehandler_codegen/Props.h>
#import <react/renderer/components/rngesturehandler_codegen/RCTComponentViewHelpers.h>
Expand Down Expand Up @@ -261,9 +263,18 @@ - (void)tryAttachNativeHandlersToChildView
{
RNGestureHandlerManager *handlerManager = [RNGestureHandlerModule handlerManagerForModuleId:_moduleId];

RNGHUIView *view = self.subviews[0];

if ([view isKindOfClass:[RCTViewComponentView class]]) {
RCTViewComponentView *componentView = (RCTViewComponentView *)view;
if (componentView.contentView != nil) {
view = componentView.contentView;
}
}

for (NSNumber *handlerTag in _nativeHandlers) {
[handlerManager.registry attachHandlerWithTag:handlerTag
toView:self.subviews[0]
toView:view
withActionType:RNGestureHandlerActionTypeNativeDetector];

[_attachedHandlers addObject:handlerTag];
Expand Down
Loading