I m目前正在开展一个快速倡议项目,并利用国王渔民图书馆展示图像。 然而,Im面临一个使用<代码>KFImage的图像显示问题,带有URL。
下面是我守则的简化版本:
import SwiftUI
import Kingfisher
struct TopMoviePreview: View {
var movie: Movie
func isCategoryLast(_ cat: String) -> Bool {
let catCount = movie.categories.count
if let index = movie.categories.firstIndex(of: cat) {
if index + 1 != catCount {
return false
}
}
return true
}
var body: some View {
ZStack {
KFImage(URL(string:"https://picsum.photos/seed/picsum/200/300")!)
.resizable()
.scaledToFill()
.clipped()
VStack {
Spacer()
HStack {
ForEach(movie.categories, id: .self) { category in
HStack {
Text(category)
.font(.footnote)
.foregroundColor(.black)
if !isCategoryLast(category) {
Image(systemName: "circle.fill")
.foregroundColor(.blue)
.font(.system(size: 3))
}
}
}
}
HStack {
Spacer()
SmallVerticalButton(text: "My List", isOnImage: "checkmark", isOffImage: "plus", isOn: true) {
//
}
Spacer()
WhiteButton(text: "Play", imageName: "play.fill") {
//
}
.frame(width: 120)
Spacer()
SmallVerticalButton(text: "Info", isOnImage: "info.circle", isOffImage: "info.circle", isOn: true) {
//
}
Spacer()
}
}
.background(
// LinearGradient.blackOpacityGradient
// .padding(.top, 250)
)
}
.foregroundColor(.white)
}
}
#Preview {
TopMoviePreview(movie: movie2)
}
The issue is that the image is not being displayed as expected. I have verified that the URL is correct, and if I replace it with a static image, it works fine. It seems to be related to the asynchronous loading of the image.
I have tried using different approaches, including checking if the URL is valid and force-unwrapping it, but the problem persists. The placeholder image is also not showing up.
如果对可能产生这一问题和我如何解决这一问题有任何见解或建议,将受到高度赞赏。
Thank you!
它没有显示任何形象的最新预览