[FDTemplateLayoutCell] Warning once only: Cannot get a proper cell height (now 0) from '- systemFittingSize:'(AutoLayout). You should check how constraints are built in cell, making it into 'self-sizing' cell.
bug fix 解决方案
- 出现此问题是你的Cell 在设置Autolayout时,没有设置子控件距离父类底部的距离导致无法计算出高度。所以为0
marginLine.snp.makeConstraints { (make) in
make.top.equalTo(timeLabel.snp.bottom).offset(13)
make.left.equalTo(iconImageView)
make.height.equalTo(0.5)
make.centerX.equalToSuperview()
make.bottom.equalToSuperview().priority(.high)
}
- 还有一个可能的原因是tableView的宽度在某种特殊情况下为0
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let contenArr: [CollectionAndHistoryContentModel] = contentArray[indexPath.section].1
let model: CollectionAndHistoryContentModel = contenArr[indexPath.row]
let tableViewW = tableView.width
// ableView的宽度在某种特殊情况下为0
if tableViewW > 0 {
let rowHeight = tableView.fd_heightForCell(withIdentifier: reuseID, cacheBy: indexPath) { (cell) in
guard let _cell = cell as? CollectionAndHistoryContentCell else { return }
_cell.contentModel = model
}
return rowHeight
} else {
return 0
}
}
image.png
网友评论