首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIImageView+Kingfisher在ASCellNode缺失图像中的应用

UIImageView+Kingfisher在ASCellNode缺失图像中的应用
EN

Stack Overflow用户
提问于 2016-06-06 09:21:37
回答 1查看 526关注 0票数 1

我有一个CollectionView,它的细胞是BubbleNode: ASCellNode

我使用翠鸟作为我的主要ImageDownloaderImageCache。我有一个imageView,我用initWithViewBlock:将它封装在一个ASDisplayNode中。

代码语言:javascript
复制
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)
    // ...
}

第一次,图像被正确下载和显示,但是在滚动和重新显示之后,图像就消失了,只显示背景颜色。

The Point当我点击rect时,它会显示图像!

EN

回答 1

Stack Overflow用户

发布于 2016-10-08 08:35:28

代码语言:javascript
复制
let cell = tableView.dequeueReusableCell(withIdentifier: "AnswerCell", for: indexPath) as! CustomAnswerViewCell

为您的单元格使用此方法

..。

代码语言:javascript
复制
//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")
                    }
                }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37653756

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档