Hello,
I'm trying to capture a .png of a view in my application. ImageRenderer is producing this .png file and is able to pass it to Messages and Mail successfully. However, when I press "print" in the ShareLink dialog, the dialog just disappears and nothing happens.
If I save that file to the device, then open the photo from the Photos or Files app, the print dialog works.
A thread on StackOverflow suggests writing the .png file as data to the documents directory, then passing the URL to the image file as the item within the ShareLink. I haven't been able to get this to work - it just passes a 151 byte URL file.
Am I doing something incorrectly? Is this an error within SwiftUI?
Thanks for your guidance.
@MainActor
func render() {
let renderer = ImageRenderer(content: PrintView(route: $route))
renderer.scale = displayScale
if let uiImage = renderer.uiImage {
renderedImage = Image(uiImage: uiImage)
}
}
@State private var renderedImage = Image(systemName: "photo")
ShareLink("Export", item: renderedImage, preview: SharePreview(Text("Shared image"), image: renderedImage))