Open grand-china opened 5 years ago
cache the height to model, may is anythings you want
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: cellIdForMessage(msg:array[safe: indexPath.row]), for: indexPath) if let model = array[safe: indexPath.row] { cell.reloadData(data: model as Any) if (model.cellHeigth > CGFloat(0)) == false { let size = cell.contentView.systemLayoutSizeFitting(CGSize(width: YYScreenSize().width, height: 0), withHorizontalFittingPriority: .required, verticalFittingPriority: .fittingSizeLevel) model.cellHeigth = size.height } } return cell; }
无论MVC还是MVVM-C,M都不应和V耦合
cache the height to model, may is anythings you want