rx_itemsWithCellFactory 调用语法
rx_itemsWithCellFactory call syntax
在 RxSwift 示例中,这有效:
viewModel.rows
.bindTo(resultsTableView.rx_itemsWithCellIdentifier("WikipediaSearchCell")) { (_, viewModel, cell: WikipediaSearchCell) in
cell.viewModel = viewModel
}
.addDisposableTo(disposeBag)
如何使用rx_itemsWithCellFactory来写?
我花了一段时间才搞定,google 还没有帮助。我希望它能为你节省几分钟
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)
在 RxSwift 示例中,这有效:
viewModel.rows
.bindTo(resultsTableView.rx_itemsWithCellIdentifier("WikipediaSearchCell")) { (_, viewModel, cell: WikipediaSearchCell) in
cell.viewModel = viewModel
}
.addDisposableTo(disposeBag)
如何使用rx_itemsWithCellFactory来写?
我花了一段时间才搞定,google 还没有帮助。我希望它能为你节省几分钟
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)