UITableView, Image in cell isn't showing, despite showing in UI View Hierachy inspector

I use a UITableView with custom UITableViewCells. In the cells I have a UIImageView. I assign an image to that image view from a url from my model. All this have been working fine until now.

When the cell is returned in cellForRowAtIndexPath, the image is fetched through a UIImageView extension and assigned to the image property when the async fetch returns.

  • What am I doing wrong with allowsFractionalUnits on NSDateComponentsFormatter?
  • Swift 2.0 code works in Xcode but not in Playground
  • Calling a Swift class factory method with leading dot notation?
  • Objective-C method conflicts with optional requirement method Swift
  • Instance member cannot be used on type of custom class
  • How can I get the URL from webView in swift
  • The image doesn’t show in the UIImageView, dispite having worked before (maybe this problem occured after Xcode 8 was released)

    What’s even more strange, it appear right in the UI View Hierachy Inspector in Xcode.

    What’s going on??

    Screenshot from device:

    Screenshot from device

    Screenshot from UI View Hierachy Inspector in Xcode

    enter image description here

    2 Solutions Collect From Internet About “UITableView, Image in cell isn't showing, despite showing in UI View Hierachy inspector”

    Move your code that changes corner radius from awakeFromNib to layoutSubviews in your cell subclass like the example below. This should fix it.

        override func layoutSubviews() {
            super.layoutSubviews()
            self.contentView.layoutIfNeeded()
            imageView.layer.cornerRadius = CGRectGetHeight(imageView.bounds) / 2.0
            imageView.clipsToBounds = true
        }
    

    You can also try changing it in your tableView class.

    Like this:

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    
            let cell = tableView.dequeueReusableCell(withIdentifier: "yourCellIdentifier", for: indexPath) as! yourCellClassName //Change this to your cell
    
            cell.imageView.layer.cornerRadius = 6
            cell.imageView.clipsToBounds = true
    
            return cell
       }
    

    Hope it will help you.