我想知道是否有任何代码示例RxSwift
当我可以在一个表视图中使用多个自定义单元格时。例如,我有两个部分,第一部分有 10 个单元格,类型为CellWithImage
标识符和第二部分有 10 个带有类型的单元格CellWithVideo
标识符。
例如,我创建的所有图解和代码示例仅使用一种细胞类型RxSwift TableView 示例 https://github.com/ReactiveX/RxSwift/blob/master/RxExample/RxExample/Examples/SimpleTableViewExample/SimpleTableViewExampleViewController.swift
谢谢你的帮助
您可以在没有 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)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)