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
无法加载第一个 View
第一次向下滚动看不到图像 如果想看图片,你必须向上滚动后下来
layoutIfNeeded
没有解决,我不知道
一次调用图像后将看到它的动态,
最佳答案
我认为没有任何错误,请检查您的网址不为空,也许图像尺寸太大。
//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"))
关于ios - UITableViewCell 中的 Swift KingFisher 来自 Url 的图像不是动态的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51626289/