Reputation: 4302
I use a UITableView
with custom UITableViewCell
s. 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.
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 UI View Hierachy Inspector in Xcode
Upvotes: 0
Views: 1525
Reputation: 735
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
}
Upvotes: 2
Reputation: 3631
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.
Upvotes: 0