diff --git a/Yattee/Views/Components/ShareSheet.swift b/Yattee/Views/Components/ShareSheet.swift index eae76102..4c1e4d20 100644 --- a/Yattee/Views/Components/ShareSheet.swift +++ b/Yattee/Views/Components/ShareSheet.swift @@ -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) {} diff --git a/Yattee/Views/Components/VideoSwipeActionsModifier.swift b/Yattee/Views/Components/VideoSwipeActionsModifier.swift index cf4b7fef..28bed229 100644 --- a/Yattee/Views/Components/VideoSwipeActionsModifier.swift +++ b/Yattee/Views/Components/VideoSwipeActionsModifier.swift @@ -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)