我想解决这个真的很慢,缓慢滚动在我的桌子上。慢速Tableview与自定义单元格的图像,Swift 3和核心数据
我使用核心数据封装器AERecord获取数据,并且它滚动而不cell.toneImage.image = UIImage(named: tone.image)
平滑的图像是不是大(350 X 170),但DEF只要我滚动冻结用于第二足以加载新图像。
我检查了模拟器中的混合图像等。它可能是数据被提取+同时加载图像?任何想法或建议?
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! mwCellTableViewCell
self.configureCell(cell, atIndexPath: indexPath)
return cell
}
func configureCell(_ cell: mwCellTableViewCell, atIndexPath indexPath: IndexPath) {
if let frc = fetchedResultsController {
if let tone = frc.object(at: indexPath) as? Tone {
// set data
cell.toneTitle.text = tone.name.uppercased()
let img:UIImage = tone.fav ? #imageLiteral(resourceName: "likeBtnOn") : #imageLiteral(resourceName: "likeBtnOff")
cell.favButton.setImage(img, for: .normal)
cell.favButton.tag = indexPath.row
cell.favButton.addTarget(self, action: #selector(favme(_:)), for: .touchUpInside)
cell.toneImage.image = UIImage(named: tone.image)
cell.toneImage.layer.cornerRadius = 8.0
cell.toneImage.clipsToBounds = true
}
}
}
你不应该获取这样的从'CoreData'数据之前获取的图像。如果你在'cellForRowAt'中获取它,每次单元被重用时它都会获取数据。您最好在UITableView代表链之外获取数据。如'viewDidLoad'。 – Ryan