为了从防火墙存储中检索图像并将其显示在UI中,我需要在其他主体中编写什么?
public func downloadFile(url: String){
var img: Image?
let storage = Storage.storage()
let storageRef = storage.reference()
let imageRef = storageRef.child("Wallpapers/Cars/Wallpaper1.jpg")
imageRef.downloadURL { (url, err) in
if let err = err{
print("Error! Unable to download")
}
else{
}
}
}发布于 2020-04-17 18:30:57
对于5,您可以使用以下内容:
let Ref = Storage.storage().reference(forURL: yourUrl)
Ref.getData(maxSize: 1 * 1024 * 1024) { data, error in
if error != nil {
print("Error: Image could not download!")
} else {
yourImageView.image = UIImage(data: data!)
}
}希望能帮上忙..。
发布于 2020-09-04 07:45:12
这可能是一种方式:
// Create a reference to the file you want to download
let storageRef = FirebaseStorage.StorageReference()
let imgsRef = storageRef.child(imgURL)
// Fetch the download URL
imgsRef.downloadURL { url, error in
if error != nil {
// Handle error
} else {
// Get the image
URLSession.shared.dataTask(with: url!) { data, response, error in
guard let data = data, let image = UIImage(data: data) else { return }
RunLoop.main.perform {
self.initialImage = image
}
}.resume()
}
}https://stackoverflow.com/questions/61277647
复制相似问题