RxDataSources icon indicating copy to clipboard operation
RxDataSources copied to clipboard

HeaderView is not updating when collectionview's datasource is changed.

Open ashok1089 opened this issue 5 years ago • 6 comments

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.

ashok1089 avatar Jul 26 '19 14:07 ashok1089

I am having the same issue. The header is updated when the view is recycled.

jeremiahk avatar Nov 18 '19 17:11 jeremiahk

@ashok1089 Are you sure, you configured exactly identifier type of header?

trongnhan68 avatar Mar 24 '20 04:03 trongnhan68

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.

ashok1089 avatar Mar 24 '20 17:03 ashok1089

Let try to implement decideViewTransition: { (datasource, collectionView, changeset ) in {} when you need reload header just return .reload otherwise return .animated. (not tested)

trongnhan68 avatar Apr 05 '20 13:04 trongnhan68

awesome! that works. thanks

ashok1089 avatar Jul 10 '20 14:07 ashok1089

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
                }
            }

polbins avatar Dec 01 '20 20:12 polbins