[英]Swift KingFisher in UITableViewCell image From Url not dynamical
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
没有解决我不知道
一次调用图片后,它会动态显示,
我不认为有任何错误,请检查您的URL是否为空并且图像尺寸是否很大。
//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"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.