Set popover anchor for share sheets to fix iPad crash

UIActivityViewController is presented as a popover on iPad and requires an
anchor; without a sourceView/barButtonItem UIKit aborts in
-[UIPopoverPresentationController presentationTransitionWillBegin]. Set
sourceView/sourceRect on both the direct presentation in the swipe-actions
modifier and the ShareSheet representable.

Fixes a SIGABRT seen in TestFlight build 261.
This commit is contained in:
Arkadiusz Fal
2026-05-12 23:54:57 +02:00
parent 2ed0dc72be
commit 926c6ebc97
2 changed files with 18 additions and 1 deletions

View File

@@ -202,6 +202,16 @@ struct VideoSwipeActionsModifier: ViewModifier {
while let presented = topVC.presentedViewController {
topVC = presented
}
// On iPad UIActivityViewController is presented as a popover and
// requires an anchor; without sourceView/barButtonItem UIKit aborts
// in -[UIPopoverPresentationController presentationTransitionWillBegin].
if let popover = activityVC.popoverPresentationController {
popover.sourceView = topVC.view
popover.sourceRect = CGRect(x: topVC.view.bounds.midX,
y: topVC.view.bounds.midY,
width: 0, height: 0)
popover.permittedArrowDirections = []
}
topVC.present(activityVC, animated: true)
}
#elseif os(macOS)