以編程方式將視圖添加到tableView單元格中,從而導致滾動干擾和速度變慢。我在代理函數「CellForRowAt」中以編程方式將視圖添加到單元格中。我通過委託函數「WillDisplay」嘗試了它,但結果是一樣的。 實現這一目標的最佳解決方案是什麼?以編程方式將視圖添加到tableView單元格中,使滾動乾和慢
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier:
"cell", for: indexPath) as! CustomCell
addViewsInCell(cell: cell, indexPath: indexPath)
return cell
}
func addViewsInCell(cell: CustomCell, indexPath: IndexPath) {
//here i am adding some views programmatically
for i in 0..<3 {
let customView: CustomView = Bundle.main.loadNibNamed("CustomView", owner: self, options: nil)![0] as! customView
cell.customViewPlacement.addSubview(customView)
}
}
您能否請出示您的代碼? –
本週早些時候我的水晶球破裂了,你可以發佈一些代碼嗎? –
傢伙,請參閱最新的問題。 –