在我将图片上传到 Firebase 并将 img url 存储在帖子选项卡上后,它会转换回主供稿选项卡(索引 = 0)。在我向下滚动并备份或切换选项卡视图之前,最新的图像永远不会显示。有什么建议吗?
这是我的上传,它使用了@Binding var tabIndex: Int
UploadPostViewModel.shared.uploadPost(info: postInfo) { (complete, msg) in
if !complete {
alertTitle = "Upload Post Error"
alertMessage = "\(msg)"
showAlert.toggle()
return
} else {
caption = ""
image = nil
tabIndex = 0
}
在我的提要单元中
if postCellVM.post.postImgUrl.isEmpty {
Rectangle()
.fill(colorScheme == .dark ? Color.black : Color.white)
.frame(width: 100, height: 5)
} else {
KFImage(URL(string: postCellVM.post.postImgUrl))
.placeholder {
Image(systemName: "photo.fill")
.resizable()
.scaledToFit()
.foregroundColor(colorScheme == .dark ? Color.white : Color.black)
}.retry(maxCount: 3, interval: .seconds(5))
.resizable()
.scaledToFit()
.frame(maxHeight: 440)
}