UITableView-FDTemplateLayoutCell

2020-10-12  本文已影响0人  阿拉斯加的狗

[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 解决方案

        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)
        }
    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
上一篇 下一篇

猜你喜欢

热点阅读