File tree Expand file tree Collapse file tree 5 files changed +24
-6
lines changed
Expand file tree Collapse file tree 5 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -380,7 +380,7 @@ - (instancetype)initWithFrame:(CGRect)frame
380380 _bridge = bridge;
381381 self.reactTag = reactTag;
382382 _touchHandler = [[RCTTouchHandler alloc ] initWithBridge: _bridge];
383- [self addGestureRecognizer: _touchHandler ];
383+ [_touchHandler attachToView: self ];
384384 [_bridge.uiManager registerRootView: self withSizeFlexibility: sizeFlexibility];
385385 self.layer .backgroundColor = NULL ;
386386 }
Original file line number Diff line number Diff line change 1616@interface RCTTouchHandler : UIGestureRecognizer
1717
1818- (instancetype )initWithBridge : (RCTBridge *)bridge NS_DESIGNATED_INITIALIZER;
19+
20+ - (void )attachToView : (UIView *)view ;
21+ - (void )detachFromView : (UIView *)view ;
22+
1923- (void )cancel ;
2024
2125@end
Original file line number Diff line number Diff line change @@ -64,6 +64,21 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
6464
6565RCT_NOT_IMPLEMENTED (- (instancetype )initWithTarget:(id )target action:(SEL )action)
6666
67+ - (void )attachToView:(UIView *)view
68+ {
69+ RCTAssert (self.view == nil , @" RCTTouchHandler already has attached view." );
70+
71+ [view addGestureRecognizer: self ];
72+ }
73+
74+ - (void )detachFromView : (UIView *)view
75+ {
76+ RCTAssertParam (view);
77+ RCTAssert (self.view == view, @" RCTTouchHandler attached to another view." );
78+
79+ [view removeGestureRecognizer: self ];
80+ }
81+
6782typedef NS_ENUM (NSInteger , RCTTouchEventType) {
6883 RCTTouchEventTypeStart,
6984 RCTTouchEventTypeMove,
Original file line number Diff line number Diff line change 99
1010#import " RCTModalHostView.h"
1111
12+ #import < UIKit/UIKit.h>
13+
1214#import " RCTAssert.h"
1315#import " RCTBridge.h"
1416#import " RCTModalHostViewController.h"
1517#import " RCTTouchHandler.h"
1618#import " RCTUIManager.h"
1719#import " UIView+React.h"
1820
19- #import < UIKit/UIKit.h>
20-
2121@implementation RCTModalHostView
2222{
2323 __weak RCTBridge *_bridge;
@@ -87,7 +87,7 @@ - (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)atIndex
8787{
8888 RCTAssert (_reactSubview == nil , @" Modal view can only have one subview" );
8989 [super insertReactSubview: subview atIndex: atIndex];
90- [subview addGestureRecognizer: _touchHandler ];
90+ [_touchHandler attachToView: subview ];
9191 subview.autoresizingMask = UIViewAutoresizingFlexibleHeight |
9292 UIViewAutoresizingFlexibleWidth;
9393
@@ -99,7 +99,7 @@ - (void)removeReactSubview:(UIView *)subview
9999{
100100 RCTAssert (subview == _reactSubview, @" Cannot remove view other than modal view" );
101101 [super removeReactSubview: subview];
102- [subview removeGestureRecognizer: _touchHandler ];
102+ [_touchHandler detachFromView: subview ];
103103 _reactSubview = nil ;
104104}
105105
Original file line number Diff line number Diff line change 1212#import " RCTBridge.h"
1313#import " RCTModalHostView.h"
1414#import " RCTModalHostViewController.h"
15- #import " RCTTouchHandler.h"
1615#import " RCTShadowView.h"
1716#import " RCTUtils.h"
1817
You can’t perform that action at this time.
0 commit comments