我有一个CollectionView
,其单元格为BubbleNode: ASCellNode
。
我使用 Kingfisher 作为我的主ImageDownloader
和ImageCache
。我有一个imageView,我将其包含在ASDisplayNode
initWithViewBlock:
内。
init() {
// ...
imageNode = ASDisplayNode(viewBlock: {
let imageView = UIImageView()
imageView.kf_setImageWithURL(url, placeholderImage: nil, optionsInfo: [KingfisherOptionsInfoItem.CacheMemoryOnly], progressBlock: nil, completionHandler: nil)
imageView.clipsToBounds = true
imageView.layer.cornerRadius = 12
imageView.backgroundColor = UIColor.redColor()
return imageView
})
addSubnode(imageNode)
// ...
}
首次下载并正确显示图像,但滚动和重新显示后,图像消失,仅显示背景颜色。
点是当我点击矩形时,它会显示图像!
答案 0 :(得分:0)
let cell = tableView.dequeueReusableCell(withIdentifier: "AnswerCell", for: indexPath) as! CustomAnswerViewCell
为您的单元格使用此方法
...
//Download image
if UIImage(named: "no-image-found") == question.questionImage {
//cell.downloadImage(imageName: question.imageName)
if let url = URL(string: serverString+"photo?filename="+question.imageName) {
headerCell.questionImageView.kf.setImage(with: url)
//question.questionImage = headerCell.questionImageView.image
headerCell.questionImageView.contentMode = .scaleAspectFit
} else {
print("Bad url")
}
}