英文:
SwiftUI: Missing actions from share sheet when using ShareLink with SharePreview
问题
我目前在开发一个iOS 16应用程序时遇到了实施SwiftUI共享面板的问题。我使用ShareLink来实现共享面板,我想要自定义它并添加SharePreview。我要共享的项目是一个简单的链接。
我按照苹果的文档中描述的方式来实现了共享面板:
ShareLink(
item: URL(string: "https://developer.apple.com/xcode/swiftui/")!,
preview: SharePreview(
"SwiftUI",
image: Image("SwiftUI")
)
)
结果是一个奇怪的共享面板,只有一个用于创建"新快速笔记"的操作。
我想要实现的是一个"正常"的共享面板,包含所有可用的共享选项。但是,只有通过删除自定义的SharePreview,我才能实现这一点,如下所示:
ShareLink(
item: URL(string: "https://developer.apple.com/xcode/swiftui/")!
)
所以,这是一个bug吗,还是我在做什么错了?非常感谢任何帮助
英文:
I am currently having issues with the implementation of a SwiftUI share sheet for an iOS16 application that I want to develop. I Implemented the share sheet using ShareLink that I want to customize with a SharePreview. The item I want to share is a simple link.
I implemented the share sheet exactly like described in Apple's documentation:
ShareLink(
item: URL(string: "https://developer.apple.com/xcode/swiftui/")!,
preview: SharePreview(
"SwiftUI",
image: Image("SwiftUI")
)
)
This, results in a weird share sheet that only has one action for creating a "New Quick Note".
What I want to achieve, however, is a "normal" share sheet with all available share options. But I was only able to make this happen by deleting the custom SharePreview, as shown below.
ShareLink(
item: URL(string: "https://developer.apple.com/xcode/swiftui/")!
)
So: Is this the bug or am I doing something wrong here? Any help is much appreciated
答案1
得分: 2
I'm pretty sure this is a bug. I get the same issue when sharing a simple String and providing a preview image.
I was able to get all of the share options by adding a blank message to the ShareLink.
ShareLink(item: "FuzzBot Export", message: Text(""),
preview: SharePreview("FuzzBot Export", image: Image("fuzzbot")) )
Hope this helps!
英文:
I'm pretty sure this is a bug. I get the same issue when sharing a simple String and providing a preview image.
I was able to get all of the share options by adding a blank message to the ShareLink.
ShareLink(item: "FuzzBot Export", message: Text(""),
preview: SharePreview("FuzzBot Export", image: Image("fuzzbot")) )
Hope this helps!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论