RxDataSources
RxDataSources copied to clipboard
HeaderView is not updating when collectionview's datasource is changed.
I am changing my data source type from "RxCollectionViewSectionedReloadDataSource" to "RxCollectionViewSectionedAnimatedDataSource".
In RxCollectionViewSectionedReloadDataSource, making changes to the data source updates my header view But in RxCollectionViewSectionedAnimatedDataSource, it does not update my header view.
Is this an expected behavior, please help.
I am having the same issue. The header is updated when the view is recycled.
@ashok1089 Are you sure, you configured exactly identifier type of header?
Below is the code I am using to configure HeaderView. dataSource.configureSupplementaryView = { (dataSource, collectionView, kind, indexPath) in // configure headerView return headerView } the above configuration never gets called with the new "RxCollectionViewSectionedAnimatedDataSource" when making changes to the datasource.
Let try to implement decideViewTransition: { (datasource, collectionView, changeset ) in {} when you need reload header just return .reload otherwise return .animated. (not tested)
awesome! that works. thanks
I experienced the same problem with a dynamic header, and upon searching I found this issue and also this answer from StackOverflow.
What I noticed is that on decideViewTransition
, the changeset is actually empty when we only change the header.
So I applied @trongnhan68's solution sparingly, only when the changeset is empty we do reload:
decideViewTransition: { _, _, changeset in
if changeset.isEmpty {
return ViewTransition.reload
} else {
return ViewTransition.animated
}
}