Swiftui 中的 AsyncImage 不显示图像
Image doesn't appear with AsyncImage in Swiftui
我在 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
}
}
尝试使用 ZStack
包裹 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))
}
}
}
我在 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
}
}
尝试使用 ZStack
包裹 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))
}
}
}