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
尚未解决,我不知道
一次调用图片后,它会动态显示,
答案 0 :(得分:0)
我不认为有任何错误,请检查您的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"))