首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UITableViewCell图像中的Swift KingFisher不是动态的

UITableViewCell图像中的Swift KingFisher不是动态的
EN

Stack Overflow用户
提问于 2018-08-01 14:01:30
回答 1查看 813关注 0票数 1
代码语言:javascript
复制
 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = chatableView.dequeueReusableCell(withIdentifier: "SendMsgCell", for: indexPath) as! SendMsgTableViewCell
    let msg = chatList[indexPath.row]
    if msg.emoURL != nil{
                cell.sticonFrame.kf.setImage(with: getEmojiFromURL(msg.emoURL!),completionHandler:{
                    (image, error, cacheType, imageUrl) in
                    if image != nil{
                        cell.sticonFrame.alpha = 1
                    }else{
                        cell.sticonFrame.alpha = 0
                        cell.sticonFrame.image = nil
                    }
                })
                cell.layoutIfNeeded()
            }else{
                cell.sticonFrame.alpha = 0
                cell.sticonFrame.image = nil
        }
    return cell
}

KingFisher无法加载第一个视图

首先向下滚动无法看到图像,如果想看到图像,则必须在向上滚动后才能向下滚动

layoutIfNeeded还没解决我不知道

只需调用一次图片,就可以看到它的动态。

EN

回答 1

Stack Overflow用户

发布于 2018-08-01 20:30:56

我不认为有什么错误,请检查您的网址不是空的,也许图片太大了。

代码语言:javascript
复制
//go for this appoarch
class INSUtilities {
class func setImage(onImageView image:UIImageView,withImageUrl imageUrl:String?,placeHolderImage: UIImage) {

        if let imgurl = imageUrl{
            image.kf.indicatorType = IndicatorType.activity
            image.kf.setImage(with: URL(string: imgurl), placeholder: placeHolderImage, options: nil, progressBlock: nil, completionHandler: { (image, error, cacheType, url) in
            })
        }
        else{
            image.image = placeHolderImage
        }
    }
}

//incellclass call like this

//logoImg is the name of imageView

INSUtilities.setImage(onImageView: cell.sticonFrame, withImageUrl: logo!, placeHolderImage: #imageLiteral(resourceName: "pic_PlaceHolder"))
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51626289

复制
相关文章

相似问题

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