【发布时间】:2021-02-15 17:20:35
【问题描述】:
我有一个 tableView,但是当它加载单元格时,它看起来很难看,因为图像需要一两秒钟才能加载。我有一个要显示的加载程序,然后当所有单元格都加载完毕后,我想显示tableView 和隐藏加载器。如何判断 tableView 何时完成加载并显示 tableView?
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "MainTableViewCell",
for: indexPath) as! MainTableViewCell
let payment = self.payments[indexPath.row]
if let profileImageUrl = payment.picture {
cell.profilePicture.loadImageUsingCacheWithUrlString(profileImageUrl)
cell.profilePicture.layer.cornerRadius = cell.profilePicture.frame.size.width / 2
cell.profilePicture.clipsToBounds = true
}
if payment.message == "none" {
cell.detailsLabel.text = "No Message"
} else {
cell.detailsLabel.text = "\"\(payment.message ?? "")\""
}
cell.amountLabel.textColor = UIColor.init(red: 105/255, green: 105/255, blue: 105/255, alpha: 1)
cell.amountLabel.text = "$\(payment.amount ?? "")"
return cell
}
【问题讨论】:
-
下载时应该有微调器的SDWebImage(或其他KingFisher、Alamofire+Image)怎么样:github.com/SDWebImage/SDWebImage/wiki/…
-
我有一个我想使用的自定义加载器,在我的屏幕中间...
-
你想下载所有的图片,然后用加载的图片重新加载 tableView?寻找 DispatchGroup,进入,离开,然后通知。
标签: ios swift xcode tableview cell