Ios 具有多个自定义单元格类型的RxSwift表格视图

Ios 具有多个自定义单元格类型的RxSwift表格视图,ios,swift,uitableview,swift2,rx-swift,Ios,Swift,Uitableview,Swift2,Rx Swift,我想知道当我可以在一个表视图中使用多个自定义单元格时,RxSwift是否有代码示例。例如,我有两个部分,第一部分有10个单元格,类型为CellWithImageidentifier,第二部分有10个单元格,类型为CellWithVideoidentifier 例如,我发现的所有TUT和代码示例都只使用一种单元格类型 谢谢你的帮助我用 它允许您将自定义单元格与多个部分一起使用。 如果有人感兴趣,这里是我的实现。我有一个带有游戏列表的应用程序。根据游戏是结束还是继续,我使用不同的单元格。这是我的密码

我想知道当我可以在一个表视图中使用多个自定义单元格时,
RxSwift
是否有代码示例。例如,我有两个部分,第一部分有10个单元格,类型为
CellWithImage
identifier,第二部分有10个单元格,类型为
CellWithVideo
identifier

例如,我发现的所有TUT和代码示例都只使用一种单元格类型

谢谢你的帮助

我用

它允许您将自定义单元格与多个部分一起使用。
如果有人感兴趣,这里是我的实现。我有一个带有游戏列表的应用程序。根据游戏是结束还是继续,我使用不同的单元格。这是我的密码:

在ViewModel中,我有一个游戏列表,将它们拆分为已完成/正在进行的游戏,并将它们映射到
SectionModel

let gameSections = PublishSubject<[SectionModel<String, Game>]>()
let dataSource = RxTableViewSectionedReloadDataSource<SectionModel<String, Game>>()

...

self.games.asObservable().map {[weak self] (games: [Game]) -> [SectionModel<String, Game>] in
    guard let safeSelf = self else {return []}
    safeSelf.ongoingGames = games.filter({$0.status != .finished})
    safeSelf.finishedGames = games.filter({$0.status == .finished})
    
    return [SectionModel(model: "Ongoing", items: safeSelf.ongoingGames), SectionModel(model: "Finished", items: safeSelf.finishedGames)]
}.bindTo(gameSections).addDisposableTo(bag)

您可以在不使用RxDatasource的情况下设置多个自定义单元格

    //Register Cells as you want
    tableView.register(CustomRxTableViewCell.self, forCellReuseIdentifier: "Cell")
    tableView.register(UITableViewCell.self, forCellReuseIdentifier: "BasicCell")



    ViewModel.data.bind(to: tableView.rx.items){(tv, row, item) -> UITableViewCell in

        if row == 0 {
            let cell = tv.dequeueReusableCell(withIdentifier: "BasicCell", for: IndexPath.init(row: row, section: 0))

            cell.textLabel?.text = item.birthday
            return cell
        }else{
            let cell = tv.dequeueReusableCell(withIdentifier: "Cell", for: IndexPath.init(row: row, section: 0)) as! CustomRxTableViewCell
            cell.titleLb.text = item.name
            return cell
        }

    }.disposed(by: disposeBag)

你能分享你到底是如何实现这一点的代码吗?你怎么能更新数据源中的一项<代码>数据源。仅获取sectionModels。我的模型是一个数组,我试图在用户输入后更新其中一个项目。谢谢
    //Register Cells as you want
    tableView.register(CustomRxTableViewCell.self, forCellReuseIdentifier: "Cell")
    tableView.register(UITableViewCell.self, forCellReuseIdentifier: "BasicCell")



    ViewModel.data.bind(to: tableView.rx.items){(tv, row, item) -> UITableViewCell in

        if row == 0 {
            let cell = tv.dequeueReusableCell(withIdentifier: "BasicCell", for: IndexPath.init(row: row, section: 0))

            cell.textLabel?.text = item.birthday
            return cell
        }else{
            let cell = tv.dequeueReusableCell(withIdentifier: "Cell", for: IndexPath.init(row: row, section: 0)) as! CustomRxTableViewCell
            cell.titleLb.text = item.name
            return cell
        }

    }.disposed(by: disposeBag)