HomeiOS Developmentios - Photographs from Firebase Storage in SwiftUI

ios – Photographs from Firebase Storage in SwiftUI


I’m newbie in iOS and Swift. I wish to show pictures from Firebase Storage.
In line with the tutorial https://firebase.google.com/docs/storage/ios/download-files

That is the way it ought to be achieved in View Controller

// Reference to a picture file in Firebase Storage
let reference = storageRef.baby("pictures/stars.jpg")

// UIImageView in your ViewController
let imageView: UIImageView = self.imageView

// Placeholder picture
let placeholderImage = UIImage(named: "placeholder.jpg")

// Load the picture utilizing SDWebImage
imageView.sd_setImage(with: reference, placeholderImage: placeholderImage)

so far as I do know there isn’t a View Controller in SwiftUI.

The query is the right way to put UIImageView into Picture

What I attempted to do is

import Basis
import SwiftUI
import FirebaseStorage
import FirebaseStorageUI

struct StorageImage: View {
    
    personal let path: String
    let imageView: UIImageView = UIImageView()


    init(path: String) {
        self.path = path
        let storage = Storage.storage()
        let storageRef = storage.reference()
        let reference = storageRef.baby(path)
        let placeholderImage = UIImage(named: "placeholder.jpg")
        imageView.sd_setImage(with: reference, placeholderImage: placeholderImage)
    }
    
    var physique: some View {
        if (self.imageView.picture != nil) {
            Picture(uiImage: self.imageView.picture!)
        }
        
    }
}

But it surely seems just like the picture is nil

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments