Rapsefar Rapsefar - 4 months ago 17
Swift Question

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

I use a

with custom
s. In the cells I have a
. 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
, the image is fetched through a UIImageView extension and assigned to the
property when the async fetch returns.

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


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() {
        imageView.layer.cornerRadius = CGRectGetHeight(imageView.bounds) / 2.0
        imageView.clipsToBounds = true