cosmicmind

Image in presenterImageView not displaying properly


I modified the PresenterCard sample code to use my firebase database instead of the graph library. However, it does not display the images properly. Essentially the image is not scaling to fit the view. I have

presenterImageView.contentMode = .scaleAspectFill

how can I fix this?

EDIT:

I use the following code to download the image

storageRef.getData(maxSize: 1 * 1024 * 1024) { (data, error) -> Void in
    let pic = UIImage(data: data!)
    if let image = pic {
        self.presenterImageView.frame.size.height = image.height
        Motion.async { [weak self, image = image] in
            self?.presenterImageView.image = image
        }
    }
}

card.frame.origin.x = 0
card.frame.origin.y = 0
card.frame.size.width = bounds.width

frame.size.height = card.bounds.height
presenterImageView.frame.size.height = 300

The image loads but it doesn't scale.


Solution

  • Solved my own problem. Had to remove the line:

    self.presenterImageView.frame.size.height = image.height
    

    Works fine now!