File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -119,14 +119,21 @@ - (UITargetedPreview *)contextMenuInteraction:(UIContextMenuInteraction *)intera
119
119
}
120
120
121
121
- (UITargetedPreview *)contextMenuInteraction : (UIContextMenuInteraction *)interaction previewForDismissingMenuWithConfiguration : (UIContextMenuConfiguration *)configuration API_AVAILABLE(ios(13.0 )) {
122
- UIPreviewTarget* previewTarget = [[UIPreviewTarget alloc ] initWithContainer: self center: self .reactSubviews.firstObject.center];
122
+ UIView *hostView = self.reactSubviews .firstObject ;
123
+
124
+ if (!hostView.window ) {
125
+ // The view is no longer available; it was unmounted.
126
+ return nil ;
127
+ }
128
+
129
+ UIPreviewTarget* previewTarget = [[UIPreviewTarget alloc ] initWithContainer: self center: hostView.center];
123
130
UIPreviewParameters* previewParams = [[UIPreviewParameters alloc ] init ];
124
131
125
132
if (_previewBackgroundColor != nil ) {
126
133
previewParams.backgroundColor = _previewBackgroundColor;
127
134
}
128
-
129
- return [[UITargetedPreview alloc ] initWithView: self .reactSubviews.firstObject
135
+
136
+ return [[UITargetedPreview alloc ] initWithView: hostView
130
137
parameters: previewParams
131
138
target: previewTarget];
132
139
}
You can’t perform that action at this time.
0 commit comments