I wasn’t really able to find this in docs or somewhere, but is there a way to provide custom header and footer loaded from nib, using RxDatasources?
For example, I am dequeuing a cell like this:
let dataSource = RxTableViewSectionedAnimatedDataSource<CommentsSectionModel>(
configureCell: { dataSource, tableView, indexPath, item in
if let cell = tableView.dequeueReusableCell(withIdentifier:
item.cellIdentifier, for: indexPath) as? BaseTableViewCell{
cell.setup(data: item.model)
return cell
}
return UITableViewCell()
})
I don’t see that there is something along with configureCell
(except titleForHeaderInSection
) to let me dequeue/configure reusable header/footer (something what standard viewForHeaderInSection
and viewForFooterInSection
delegate methods are providing).
2
Answers
A custom Header/Footer is not part of the UITableViewDataSource interface so it’s not something that an RxDataSource can provide.
If you want, you can follow my article on how to Convert a Swift Delegate to RxSwift Observables and make a table view delegate for this… It’s not part of the library because table view delegates don’t conform to a push interface.
@DanielT answer above work for my case, but it only show 1 section header/footer only. I updated it like this and it’s fixed: