2

UIImageView images are not loading either with downloading with Alamofire or using URL to convert to a data object and convert data object to a UIImage. My images on UITableViewCells are working but not the UIImageviews standalone in a UIView. It is giving me a blank.

UIImageViews: They are a subview of a UIView which is a subview of a UITableView

Here it is the code that Im using:

let imageURL = URL(string: _imageUrl)
let imageData = try? Data(contentsOf: imageURL!)
imageView.image = UIImage(data: imageData!)

Here is the extension that I'm using with Alamofire:

extension UIImageView {
 func donwloadImageFrom(_ imageURL: String, contentMode: UIViewContentMode) {
    let stringUrl = URL(string: imageURL)!
    Alamofire.request(stringUrl, method: .get).response(completionHandler: { response in
        if let imageData = response.data {
            DispatchQueue.main.async(execute: {
                self.contentMode = contentMode
                self.image = UIImage(data: imageData)
            })
        }
    })
  }
}
cengo
  • 151
  • 1
  • 6
  • 2
    I am having the same issues. First I thought it had something todo with the image loading library I was using but. Straight up loading an url doesnt seem to work either – Jochem Toolenaar Sep 24 '16 at 18:44
  • I found the answer in this [question](http://stackoverflow.com/questions/39380128/ios-10-gm-with-xcode-8-gm-causes-views-to-disappear-due-to-roundedcorners-clip/39380129#39380129) – cengo Sep 24 '16 at 20:49

1 Answers1

0

I think the awakeFromNib() function bit changed. I don't know exact reason but, after adding

layoutIfNeeded()

into awakeFromNib(). Made it works.