gpt4 book ai didi

swift - 当我从 firebase 存储上传新图像时,imageView 不会更改图像

转载 作者:行者123 更新时间:2023-11-30 10:36:02 26 4
gpt4 key购买 nike

我尝试从网址获取图像,第一次加载正确的图像形式网址,但是当我上传新图像时,imageView 没有改变。我从控制台收到此错误:

[BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C7.1:2][0x7fa944135a30] get output frames failed, state 8196

然后我又上传了一张新图片,imageView 显示上次下载的图像,它再次显示相同的错误。问题出在哪里?

ref.child("/user").child(userID).child("UserImage").observe(DataEventType.value, with: {(data) in

let value = data.value as? String ?? ""
print("url:",value)
if let url = URL(string: value) {

URLSession.shared.dataTask(with: url, completionHandler: {(data,responds,error) in
if error != nil{
print(error!.localizedDescription)
}
else if let imageData = data{
DispatchQueue.main.async {
self.userImage.image = UIImage(data: imageData)
}
}
}).resume()

}

})

最佳答案

尝试添加 SDWEBImage pod

pod“SDWebImage”

那么你可以直接传入url

self.userImage.sd_setImage(带有:url,完成:nil)

有关 Pod 的更多信息请参见 https://cocoapods.org/pods/SDWebImage

关于swift - 当我从 firebase 存储上传新图像时,imageView 不会更改图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58012629/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com