0

I have been trying to look for this solution for a very long time, but I can not find any documentation or tutorials on it. I want to set a tabbar item to the user's profile picture. Each user can only log into the app through Facebook. The app then takes the user's profile picture from facebook and stores it in firebase storage. I want to retrieve that image and set it to a tabbar item, but unfortunately, it is not working. Here is the code I have so far:

override func awakeFromNib() {
        super.awakeFromNib()
        self.tabBarItem.title = "MY ACCOUNT"
        if self.loggedInUserUid != nil {

            let imageRef = FIRStorage.storage().reference().child((loggedInUserUid)!+"/profile_pic.jpg")

            imageRef.data(withMaxSize: 75 * 144 * 96, completion: { (data, error) -> Void in
                if error != nil {
                    print(error!)
                    return
                }
                DispatchQueue.main.async(execute: { () -> Void in
                    let image = UIImage(data: data!)
                    self.tabBarItem.image = image
                })

            }).resume()
}}

i get the error: Could not load the "" image referenced from a nib in the bundle with identifier

juelizabeth
  • 485
  • 1
  • 8
  • 31

1 Answers1

0

In the storyboard click on the image. Go to the column on the right (activate it if it's not visible by clicking on the appropriate button) and find a place that says something like "identifier". Enter a short name there. Then use this identifier instead of the path you're using. Based on the error message it looks like you've defined the image in your storyboard without an identifier. If that's true you don't need all the code to load the image manually. You should pick one method or the other. But not both. I'd love to be more specific but I'm away just now and on my phone.

Mozahler
  • 4,958
  • 6
  • 36
  • 56