Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ashok1089 opened this issue Jul 26, 2019 · 6 comments
Open

Comments

@ashok1089
Copy link

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.

@jeremiahk
Copy link

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

@trongnhan68
Copy link

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

@ashok1089
Copy link
Author

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.

@trongnhan68
Copy link

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

@ashok1089
Copy link
Author

awesome! that works. thanks

@polbins
Copy link

polbins commented Dec 1, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants