She*_*ood 0 swift swift5 swiftui
我必须在 else 正文中编写什么才能从 firebase 存储中检索图像并将其显示在 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{
}
}
}
Run Code Online (Sandbox Code Playgroud)
对于 swift 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!)
}
}
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你...
归档时间: |
|
查看次数: |
2876 次 |
最近记录: |