如果我滚动,那么只有图像在加载。这是我的代码
var nib: [Any] = Bundle.main.loadNibNamed("SampleTableViewCell", owner: self, options: nil)!
let cell = nib[0] as? SampleTableViewCell
let values = detailsArr[indexPath.row] as! SampleModel
let url = URL(string: values.imageStr)
cell?.title_Lbl.text = values.title
cell?.desccription_Lbl.text = values.description
cell?.image_View.sd_setImage(with: url)
cell?.layoutIfNeeded()
tableView.estimatedRowHeight = 370
return cell!
}
您需要将笔尖注册为 UITableView 的可重用单元格:
let sampleNib = UINib(nibName: "SampleTableViewCell", bundle: nil)
tableView.register(sampleNib, forCellReuseIdentifier: "SampleTableViewCell")
然后在tableView的dataSource方法中cellForRowAt
删除它:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let sampleCell = tableView.dequeueReusableCell(withIdentifier: "SampleTableViewCell") as! SampleTableViewCell
/*
Customise your cell here.
I suggest you make all your customisations inside the cell, and call here a function from the cell
eg.:
let values = detailsArr[indexPath.row] as! SampleModel
sampleCell.setupCell(with: values)
*/
return sampleCell
}