SwiftUI: 使用ShareLink和SharePreview时,分享面板缺少操作

huangapple go评论61阅读模式
英文:

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吗,还是我在做什么错了?非常感谢任何帮助 SwiftUI: 使用ShareLink和SharePreview时,分享面板缺少操作

英文:

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".

SwiftUI: 使用ShareLink和SharePreview时,分享面板缺少操作

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/")!
)

SwiftUI: 使用ShareLink和SharePreview时,分享面板缺少操作

So: Is this the bug or am I doing something wrong here? Any help is much appreciated SwiftUI: 使用ShareLink和SharePreview时,分享面板缺少操作

答案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!

huangapple
  • 本文由 发表于 2023年2月8日 18:07:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/75384181.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定