Swift 使用多种单元格类型重构TableView

Swift 使用多种单元格类型重构TableView,swift,uitableview,Swift,Uitableview,任何关于分解具有多种单元类型和单元大小的海量视图控制器的建议。因为每个单元格都有自己的委托,所以在文件中导航时视图控制器会变得非常混乱 或者这是针对多种单元格类型的标准方法?您将如何使用多个分区和单元构建多个。非常感谢 //Rows func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { if section == 0 && sectionArray

任何关于分解具有多种单元类型和单元大小的海量视图控制器的建议。因为每个单元格都有自己的委托,所以在文件中导航时视图控制器会变得非常混乱

或者这是针对多种单元格类型的标准方法?您将如何使用多个分区和单元构建多个。非常感谢

//Rows
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

    if section == 0 && sectionArray[0].isExpanded {
        return sectionArray.count
    } else if section == 0 && sectionArray[0].isExpanded == false {
        return sectionArray[0].section.count - 1
    }

    if section == 1 {
        return 3
    }
    return 0
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    if indexPath.section == 0 && indexPath.row == 0 {

        let cell = tableView.dequeueReusableCell(withIdentifier: "CreateFavoriteIconCell", for: indexPath) as! CreateFavoriteIconCell
        cell.delegate = self
        return cell
    }

    if indexPath.section == 1 {
        switch indexPath.row {
        case 0:
            let cell = tableView.dequeueReusableCell(withIdentifier: "CreateFavoritePhotoCell", for: indexPath) as! CreateFavoritePhotoCell
            cell.delegate = self
            return cell
        case 1:
            let cell = tableView.dequeueReusableCell(withIdentifier: "CreateFavoriteLocationCell", for: indexPath) as! CreateFavoriteLocationCell
            return cell
        case 2:
            let cell = tableView.dequeueReusableCell(withIdentifier: "CreateFavoriteDescriptionCell", for: indexPath) as! CreateFavoriteDescriptionCell
            return cell
        default:
            return tableView.cellForRow(at: indexPath)!
        }
    }
    return tableView.cellForRow(at: indexPath)!
}

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {

    if indexPath.section == 0 {
        switch indexPath.row {
        case 0:
            tableView.rowHeight = 58
        default:
            tableView.rowHeight = 0
        }
    }

    if indexPath.section == 1 {
        switch indexPath.row {
        case 0:
            tableView.rowHeight = 120
        case 1:
            tableView.rowHeight = 60
        case 2:
            tableView.rowHeight = 160
        default:
            tableView.rowHeight = 0
        }
    }

    return tableView.rowHeight
}

很抱歉实际上是关于tableView的。这里又是:你能提供更多关于你的数据源的细节以及你想要你的细胞是什么样子的吗?嗨,小薇,我可以试着和你分享一张图片。但是,我很难将电脑中的图像嵌入到问题中。新的问题界面非常混乱。你知道怎么做吗?你可以在这里找到答案-