异步图未在Swift Playgrounds 4.1 [Mac]应用程序上加载图像预览

发布于 2025-02-04 05:06:38 字数 914 浏览 3 评论 0原文

“”

上面发布的URL显示了我似乎无法解决的问题的示例。在Swift Playground的iPad版本上,Asyncimage的使用起作用,但是当我在Swift Playgrounds的Mac Verison上加载相同的代码时,图像预览每次都不会加载。

编辑:此问题仅在图像的远程加载中发生,如果我向项目添加图像,则可以加载良好。

EDIT2:下面的代码段

import SwiftUI

struct ContentView: View {
    
    var body: some View {
        Section {
            VStack {
                AsyncImage(url: URL(string: "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/1200px-Image_created_with_a_mobile_phone.png")) { image in
                    image
                        .resizable()
                        .scaledToFit()
                } placeholder: {
                    Color.red.opacity(1)
                }
                .frame(width: 200, height: 200)
                .cornerRadius(6)
            }
        }
    }
}

The URL posted above shows an example of the problem i can't seem to solve so far. On the ipad version of swift playgrounds the use of Asyncimage works, however when i load the same code on the mac verison of swift playgrounds, the image preview fails to load every time.

Edit: This problem only occurs with the remote loading of images, if i add an image to the project, it loads just fine.

Edit2: Code Snippet Below

import SwiftUI

struct ContentView: View {
    
    var body: some View {
        Section {
            VStack {
                AsyncImage(url: URL(string: "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/1200px-Image_created_with_a_mobile_phone.png")) { image in
                    image
                        .resizable()
                        .scaledToFit()
                } placeholder: {
                    Color.red.opacity(1)
                }
                .frame(width: 200, height: 200)
                .cornerRadius(6)
            }
        }
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文