Skip to content

Commit 2e301dd

Browse files
m1roxxvbuberen
authored andcommitted
fix(share_plus): only configure popover presentation on iPad
Since Xcode 26, `UIActivityViewController.popoverPresentationController` is non-nil on iPhone as well, where it returns a private `_UIActivityViewControllerPresentationController` instead of a real `UIPopoverPresentationController`. The plugin set `sourceView` unconditionally and, on iPhone with a non-empty `sharePositionOrigin`, also set `sourceRect`. Both configure anchored presentation on a controller that is not a popover controller on iPhone. Restrict every popover configuration to iPad, which is what the surrounding comment already stated as the intent. iPad behaviour, including the centre-of-view fallback added in #3769, is unchanged.
1 parent 3151839 commit 2e301dd

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

‎packages/share_plus/share_plus/ios/share_plus/Sources/share_plus/FPPSharePlusPlugin.m‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -411,22 +411,24 @@ + (void)share:(NSArray *)shareItems
411411
[activityViewController setValue:subject forKey:@"subject"];
412412
}
413413

414-
activityViewController.popoverPresentationController.sourceView =
415-
controller.view;
416-
417414
// Check if this is actually an iPad
418415
BOOL isIpad = ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad);
419416

420-
// Before Xcode 26 hasPopoverPresentationController is true for iPads and false for iPhones.
421-
// Since Xcode 26 it is true for both iPads and iPhones, so we only configure popover on iPad.
417+
// Before Xcode 26, popoverPresentationController was non-nil only on iPad.
418+
// Since Xcode 26 it is non-nil on iPhone as well, where it is a private
419+
// _UIActivityViewControllerPresentationController rather than a real
420+
// UIPopoverPresentationController. Configuring it on iPhone pushes
421+
// UIActivityViewController onto the anchored presentation path, so restrict
422+
// every popover configuration to iPad.
422423
UIPopoverPresentationController *popover =
423424
activityViewController.popoverPresentationController;
424-
BOOL hasPopoverPresentationController = (popover != NULL);
425425

426-
CGRect sourceRect = origin;
427-
if (isIpad && hasPopoverPresentationController) {
426+
if (isIpad && popover != nil) {
427+
popover.sourceView = controller.view;
428+
428429
// Flutter sends sharePositionOrigin in global (window) coordinates.
429430
// Convert to the source view's coordinate space for sourceRect.
431+
CGRect sourceRect = origin;
430432
if (controller.view.window && !CGRectIsEmpty(origin)) {
431433
sourceRect = [controller.view convertRect:origin fromView:nil];
432434
}
@@ -438,8 +440,6 @@ + (void)share:(NSArray *)shareItems
438440
CGRectGetMidY(bounds) - 1.0, 2.0, 2.0);
439441
}
440442
popover.sourceRect = sourceRect;
441-
} else if (!CGRectIsEmpty(origin)) {
442-
activityViewController.popoverPresentationController.sourceRect = origin;
443443
}
444444

445445
activityViewController.completionWithItemsHandler =

0 commit comments

Comments
 (0)