在RxSwift示例中,这有效:
viewModel.rows
.bindTo(resultsTableView.rx_itemsWithCellIdentifier("WikipediaSearchCell")) { (_, viewModel, cell: WikipediaSearchCell) in
cell.viewModel = viewModel
}
.addDisposableTo(disposeBag)
如何使用rx_itemsWithCellFactory编写它?
答案 0 :(得分:9)
我花了一段时间才得到它,谷歌还没有帮助。我希望它能为你节省几分钟
viewModel.rows
.bindTo(resultsTableView.rx_itemsWithCellFactory){
(tv, i, vm) in
let indexPath = NSIndexPath(forItem: i, inSection: 0)
let cell = tv.dequeueReusableCellWithIdentifier("WikipediaSearchCell", forIndexPath: indexPath) as! WikipediaSearchCell
cell.viewModel = vm
return cell as UITableViewCell
}
.addDisposableTo(disposeBag)