@@ -103,25 +103,26 @@ - (void)didMoveToWindow {
103
103
_initialized = YES ;
104
104
_popoverHostViewController.view .backgroundColor = _popoverBackgroundColor;
105
105
106
- UIView *sourceView = [self autoGetSourceView ];
107
- if (!sourceView) {
108
- NSLog (@" sourceView is invalid" );
109
- if (_onHide) {
110
- _onHide (nil );
106
+ [self autoGetSourceView: ^(UIView *sourceView) {
107
+ if (!sourceView) {
108
+ NSLog (@" sourceView is invalid" );
109
+ if (_onHide) {
110
+ _onHide (nil );
111
+ }
112
+ return ;
111
113
}
112
- return ;
113
- }
114
- _presented = YES ;
115
- [self updateContentSize ];
116
- _popoverHostViewController.popoverPresentationController .sourceView = sourceView;
117
- _popoverHostViewController.popoverPresentationController .sourceRect = CGRectEqualToRect (_realSourceRect, CGRectNull ) ? sourceView.bounds : _realSourceRect;
118
- _popoverHostViewController.popoverPresentationController .backgroundColor = _popoverBackgroundColor;
119
- _popoverHostViewController.popoverPresentationController .permittedArrowDirections = [self getPermittedArrowDirections ];
120
- if (!CGSizeEqualToSize (CGSizeZero , _realPreferredContentSize)) {
121
- _popoverHostViewController.preferredContentSize = _realPreferredContentSize;
122
- }
123
-
124
- [_delegate presentPopoverHostView: self withViewController: _popoverHostViewController animated: _animated];
114
+ _presented = YES ;
115
+ [self updateContentSize ];
116
+ _popoverHostViewController.popoverPresentationController .sourceView = sourceView;
117
+ _popoverHostViewController.popoverPresentationController .sourceRect = CGRectEqualToRect (_realSourceRect, CGRectNull ) ? sourceView.bounds : _realSourceRect;
118
+ _popoverHostViewController.popoverPresentationController .backgroundColor = _popoverBackgroundColor;
119
+ _popoverHostViewController.popoverPresentationController .permittedArrowDirections = [self getPermittedArrowDirections ];
120
+ if (!CGSizeEqualToSize (CGSizeZero , _realPreferredContentSize)) {
121
+ _popoverHostViewController.preferredContentSize = _realPreferredContentSize;
122
+ }
123
+
124
+ [_delegate presentPopoverHostView: self withViewController: _popoverHostViewController animated: _animated];
125
+ }];
125
126
}
126
127
}
127
128
@@ -201,16 +202,24 @@ - (void)updateContentSize {
201
202
});
202
203
}
203
204
204
- - (UIView *)autoGetSourceView {
205
- UIView *sourceView = nil ;
206
- if (_sourceViewReactTag >= 0 ) {
207
- sourceView = [_bridge.uiManager viewForReactTag: @(_sourceViewReactTag)];
208
- } else if (_sourceViewTag >= 0 ) {
209
- sourceView = [[RNPopoverTargetManager getInstance ] viewForTag: _sourceViewTag];
210
- } else if (_sourceViewGetterTag >= 0 ) {
211
- sourceView = [[RNPopoverTargetManager getInstance ] viewForGetterTag: _sourceViewGetterTag];
205
+ - (void )autoGetSourceView : (void (^)(UIView *view))completion {
206
+ if (_sourceViewNativeID) {
207
+ __block NSString *nativeID = _sourceViewNativeID;
208
+ [_bridge.uiManager rootViewForReactTag: self .reactTag withCompletion: ^(UIView *view) {
209
+ completion ([_bridge.uiManager viewForNativeID: nativeID withRootTag: view.reactTag]);
210
+ }];
211
+ } else {
212
+ UIView *sourceView = nil ;
213
+ if (_sourceViewReactTag >= 0 ) {
214
+ sourceView = [_bridge.uiManager viewForReactTag: @(_sourceViewReactTag)];
215
+ } else if (_sourceViewTag >= 0 ) {
216
+ sourceView = [[RNPopoverTargetManager getInstance ] viewForTag: _sourceViewTag];
217
+ } else if (_sourceViewGetterTag >= 0 ) {
218
+ sourceView = [[RNPopoverTargetManager getInstance ] viewForGetterTag: _sourceViewGetterTag];
219
+ }
220
+ completion (sourceView);
212
221
}
213
- return sourceView;
222
+
214
223
}
215
224
216
225
#pragma mark - Setter
0 commit comments