I'm trying to set the imageView
on a standard UITableViewCell
from a remote source using a placeholder. I have this issue regardless of using SDWebImage
or AlamofireImage
as the library.
Here is how the cell appears after the initial load:
Then, once the cell has been tapped/reloaded it appears as this:
In the storyboard, I've adjusted the row height to be 60 points instead of the standard 44 points. If I return the height to the standard 44 points, the issue is no longer present.
I believe this issue is more related to custom height of the cell rather than the library providing the placeholder. I made an issue on AlamofireImage in case it was a problem with the library but it turns out this is not the case.
How can I have the image set at the right size initially, or prevent a resize from occurring upon reload?
Here is the code from my UITableViewCell
subclass. Note that the issue occurs even if I remove the frame inset code inside of layoutSubviews
.
class CategoryTableViewCell: UITableViewCell {
var category: Category! {
didSet {
self.updateCategory(category)
}
}
override func layoutSubviews() {
super.layoutSubviews()
self.imageView?.frame = CGRectInset(self.imageView!.frame, 10, 10)
}
private func updateCategory(category: Category) {
self.textLabel?.text = category.name
self.imageView?.sd_setImageWithURL(category.largeImage ?? nil, placeholderImage: UIImage(named: "DefaultCategory"))
}
}
I've now also set the following overrides on the table view controller, bu it hasn't had any effect.
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 60;
}
override func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 60;
}