11
11
#import " UIResponder+FirstResponderTemp.h"
12
12
13
13
#import < WebKit/WebKit.h>
14
-
14
+ # import < React/RCTScrollView.h >
15
15
#import < React/RCTBridge.h>
16
16
#import < React/RCTUIManager.h>
17
17
#import < React/UIView+React.h>
18
18
#import < React/RCTUIManagerUtils.h>
19
- #import < React/RCTSurfaceHostingView.h>
20
19
21
20
#import < objc/runtime.h>
22
21
@@ -71,7 +70,7 @@ -(instancetype)init
71
70
72
71
if (self)
73
72
{
74
- [self addObserver: self forKeyPath: @" frame " options: NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew context: NULL ];
73
+ [self addObserver: self forKeyPath: @" bounds " options: NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew context: NULL ];
75
74
_inputViewsMap = [NSMapTable weakToWeakObjectsMapTable ];
76
75
_deferedInitializeAccessoryViewsCount = 0 ;
77
76
@@ -94,21 +93,20 @@ -(instancetype)init
94
93
return self;
95
94
}
96
95
97
- -(UIView *)getRootView
96
+ -(RCTRootView *)getRootView
98
97
{
99
98
UIView *view = self;
100
99
while (view.superview != nil )
101
100
{
102
101
view = view.superview ;
103
- if ([view isKindOfClass: [RCTSurfaceHostingView class ]]) {
102
+ if ([view isKindOfClass: [RCTRootView class ]])
104
103
break ;
105
- }
106
104
}
107
105
108
- if ([view isKindOfClass: [RCTSurfaceHostingView class ]]) {
109
- return view;
106
+ if ([view isKindOfClass: [RCTRootView class ]])
107
+ {
108
+ return (RCTRootView*)view;
110
109
}
111
-
112
110
return nil ;
113
111
}
114
112
@@ -171,50 +169,37 @@ -(void)layoutSubviews
171
169
[self updateBottomViewFrame ];
172
170
}
173
171
174
- - (UIScrollView*)extractUIScrollView : (UIView*)view
175
- {
176
- for (UIView* subview in view.subviews ) {
177
- if ([subview isKindOfClass: [UIScrollView class ]]) {
178
- return (UIScrollView*)subview;
179
- }
180
- }
181
-
182
- return nil ;
183
- }
184
-
185
172
- (void )initializeAccessoryViewsAndHandleInsets
186
173
{
187
174
NSArray <UIView*>* allSubviews = [self getBreadthFirstSubviewsForView: [self getRootView ]];
175
+ NSMutableArray <RCTScrollView*>* rctScrollViewsArray = [NSMutableArray array ];
188
176
189
177
for (UIView* subview in allSubviews)
190
178
{
191
179
if (_manageScrollView)
192
180
{
193
181
if (_scrollViewToManage == nil )
194
182
{
195
- if ([NSStringFromClass ([subview class ]) isEqualToString: @" RCTScrollViewComponentView" ]) {
196
- UIScrollView *scrollView = [self extractUIScrollView: subview];
197
-
198
- if ([scrollView isKindOfClass: [UIScrollView class ]])
199
- {
200
- if (_requiresSameParentToManageScrollView && subview.superview == self.superview )
201
- {
202
- _scrollViewToManage = scrollView;
203
- }
204
- else if (!_requiresSameParentToManageScrollView)
205
- {
206
- _scrollViewToManage = scrollView;
207
- }
208
-
209
- if (_scrollViewToManage != nil )
210
- {
211
- _scrollIsInverted = CGAffineTransformEqualToTransform (_scrollViewToManage.superview .transform , CGAffineTransformMakeScale (1 , -1 ));
212
- }
213
- }
183
+ if (_requiresSameParentToManageScrollView && [subview isKindOfClass: [RCTScrollView class ]] && subview.superview == self.superview )
184
+ {
185
+ _scrollViewToManage = ((RCTScrollView*)subview).scrollView ;
186
+ }
187
+ else if (!_requiresSameParentToManageScrollView && [subview isKindOfClass: [UIScrollView class ]])
188
+ {
189
+ _scrollViewToManage = (UIScrollView*)subview;
214
190
}
191
+
192
+ if (_scrollViewToManage != nil )
193
+ {
194
+ _scrollIsInverted = CGAffineTransformEqualToTransform (_scrollViewToManage.superview .transform , CGAffineTransformMakeScale (1 , -1 ));
195
+ }
196
+ }
197
+
198
+ if ([subview isKindOfClass: [RCTScrollView class ]])
199
+ {
200
+ [rctScrollViewsArray addObject: (RCTScrollView*)subview];
215
201
}
216
202
}
217
-
218
203
219
204
if ([subview isKindOfClass: NSClassFromString (@" RCTTextField" )])
220
205
{
@@ -262,11 +247,13 @@ - (void)initializeAccessoryViewsAndHandleInsets
262
247
}
263
248
}
264
249
265
- if (_scrollViewToManage != nil )
250
+ for (RCTScrollView *scrollView in rctScrollViewsArray )
266
251
{
267
- if (_scrollViewToManage. delegate == nil )
252
+ if (scrollView. scrollView == _scrollViewToManage )
268
253
{
269
- _scrollViewToManage.delegate = self;
254
+ [scrollView removeScrollListener: self ];
255
+ [scrollView addScrollListener: self ];
256
+ break ;
270
257
}
271
258
}
272
259
@@ -351,12 +338,12 @@ -(void)didMoveToWindow
351
338
352
339
-(void )dealloc
353
340
{
354
- [self removeObserver: self forKeyPath: @" frame " ];
341
+ [self removeObserver: self forKeyPath: @" bounds " ];
355
342
}
356
343
357
344
- (void )observeValueForKeyPath : (NSString *)keyPath ofObject : (id )object change : (NSDictionary <NSKeyValueChangeKey,id> *)change context : (void *)context
358
345
{
359
- _ObservingInputAccessoryViewTemp.height = self.frame .size .height ;
346
+ _ObservingInputAccessoryViewTemp.height = self.bounds .size .height ;
360
347
}
361
348
362
349
- (void )ObservingInputAccessoryViewTempKeyboardWillDisappear : (ObservingInputAccessoryViewTemp *)ObservingInputAccessoryViewTemp
0 commit comments