1

我在 TabView 中有 AsyncImage。当我这样做时,图像永远不会出现。我只看到进度条。

@available(iOS 15.0, *)

结构测试:查看{ var body:一些查看{

    VStack {
        
        TabView {
            
        
        AsyncImage(url: URL(string: "https://blckbirds.com/wp-content/uploads/2021/10/pexels-kammeran-gonzalezkeola-6128227-2.jpg"), scale: 2) { image in
                    image
                      .resizable()
                      .aspectRatio(contentMode: .fill)
                } placeholder: {
                    ProgressView()
                        .progressViewStyle(.circular)
                }
            
        }.tabViewStyle(PageTabViewStyle(indexDisplayMode: .automatic))
        
    }//V
    
}

}

4

1 回答 1

2

尝试使用 aZStack来包装AsyncImage,就像这样,对我有用:

struct TEST: View {
    
    var body: some View {
        VStack {
            TabView {
                ZStack {   // <--- here
                    AsyncImage(url: URL(string: "https://blckbirds.com/wp-content/uploads/2021/10/pexels-kammeran-gonzalezkeola-6128227-2.jpg"), scale: 2) { image in
                        image
                            .resizable()
                            .aspectRatio(contentMode: .fill)
                    } placeholder: { ProgressView().progressViewStyle(.circular) }
                }
            }.tabViewStyle(PageTabViewStyle(indexDisplayMode: .automatic))
        }
    }
    
}
于 2021-11-10T06:28:50.120 回答