mirror of
https://github.com/yattee/yattee.git
synced 2026-07-21 06:42:01 +00:00
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:
@@ -12,7 +12,14 @@ struct ShareSheet: UIViewControllerRepresentable {
|
||||
let items: [Any]
|
||||
|
||||
func makeUIViewController(context: Context) -> UIActivityViewController {
|
||||
UIActivityViewController(activityItems: items, applicationActivities: nil)
|
||||
let controller = UIActivityViewController(activityItems: items, applicationActivities: nil)
|
||||
// On iPad the activity sheet is presented as a popover and requires an
|
||||
// anchor; without one UIKit aborts in presentationTransitionWillBegin.
|
||||
if let popover = controller.popoverPresentationController {
|
||||
popover.sourceView = controller.view
|
||||
popover.permittedArrowDirections = []
|
||||
}
|
||||
return controller
|
||||
}
|
||||
|
||||
func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) {}
|
||||
|
||||
Reference in New Issue
Block a user