首页 > 解决方案 > 基于其中的 UICollectionView 单元格的 tableview 单元格的动态高度

问题描述

我有tableview单元格,里面有collectionview,还有collectionview单元格,如何根据collectionview单元格设置tableview单元格的高度?

标签: iosswiftuitableviewuicollectionview

解决方案


尝试将其添加到您的控制器中

    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return UITableView.automaticDimension
    }
    
    func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
        return UITableView.automaticDimension
    }

推荐阅读