shaps80 / SwiftUIBackports

A collection of SwiftUI backports for iOS, macOS, tvOS and watchOS
MIT License
931 stars 59 forks source link

ShareLink with an iPad #34

Closed jtressle closed 1 year ago

jtressle commented 1 year ago

Hi,

Thanks for the library. I've been using your ActivityView library! I'm posting this issue here since the ShareLink code will have the same issue I encountered with ActivityView.

I had a question / issue when presenting an acitivtysheet in iPadOS. The activitySheet is called from my main view, and not from a button like this:

NavigationView { Color.white } .activitySheet($activityItem)

In order to get this to work, I had to modify the ActivitySheet code to add the following:

controller.popoverPresentationController?.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY,width: 0,height: 0)

This is based on this thread:

https://stackoverflow.com/questions/32889680/uiactivityviewcontroller-on-ipad

Is this something you can add to this library, or is there something that I need to configure to get this to work on an iPad?

Thanks,

shaps80 commented 1 year ago

I know exactly what you’re talking about and I’m surprised I missed this. This line should absolutely be added, but you can simplify to:

controller.popoverPresentationController?.sourceRect = view.bounds

I’m on holidays atm so no access to Xcode, but if you want to submit a PR I will absolutely merge this into the next release 👍🏻

@jtressle

shaps80 commented 1 year ago

Thanks again, this is now resolved in 1.9.1 – @jtressle