Questions tagged [uicollectionviewdiffabledatasource]
75 questions
3
votes
0 answers
How to stop UICollectionViewDiffableDataSource to scroll the collection view while apply snapshot?
I have a UICollectionViewDiffableDataSource for vertical scrolling, with dynamic height cells.
Every time I call 'apply' on the datasource the collection view scrolls a bit and it doesn't look good.
How do I prevent it from scrolling?
private func…

Gili Ariel
- 572
- 1
- 6
- 18
3
votes
1 answer
UICollectionViewCompositionalLayout can't use the same sections as UICollectionViewDiffableDataSource?
I'm building a view controller with a collection view, using the (kinda) new diffable datasource and composable collectionview layout. I made my own Section and Row enums, can react to changes in my model (an array of photos), which triggers the…

Kevin Renskers
- 5,156
- 4
- 47
- 95
3
votes
2 answers
Diffable Data Source - Reload Header
What are the ways in which a UICollectionViewDiffableDataSource header can be reloaded?
I have a collection view with a header that displays user details, and rows that display posts, the model is
struct PostUser {
var user: User
var post:…

mickeysox
- 159
- 2
- 14
3
votes
2 answers
UICollectionViewDiffableDataSource is replacing data instead of updating
I am trying to understand UICollectionViewDiffableDataSource and NSDiffableDataSourceSnapshot.
I have created a very crude version below. Essentially on load it should fetch photos.
On tap of a button in the navigation bar it fetches the next page.…

Harry Blue
- 4,202
- 10
- 39
- 78
2
votes
0 answers
Custom insert / delete animations in a modern UICollectionView
How to apply custom insert / delete animation for collection view cells when using UICollectionViewCompositionalLayout with UICollectionViewDiffableDataSource?
Previously I did it by subclassing UICollectionViewLayout and overriding…

tadija
- 2,981
- 26
- 37
2
votes
0 answers
SwiftUI runtime crash ONLY IN IOS15 when using compositional layout with a uiviewrepresentable of collectionview
Getting a runtime crash when removing uiviewrepresentable of a collection view using compositional layout and a diffable data source from the screen. The view is currently in an if statement, if no data is found it uses a empty data view instead of…

Spencer Shelton
- 391
- 1
- 2
- 8
2
votes
0 answers
UICollectionView Diffable Data Source - How to retain move animation between sections, yet able to update the content of header?
I have 2 sections.
The top section contains unchecked items.
The bottom section contains checked items.
I was able to achieve nice move animation between the 2 sections, when I check/ uncheck the item.
The implementation is pretty straightforward…

Cheok Yan Cheng
- 47,586
- 132
- 466
- 875
2
votes
3 answers
Why DispatchQueue.main.async is required when using CoreData, NSFetchedResultsController and Diffable Data Source
When dealing with CoreData, NSFetchedResultsController and Diffable Data Source, I always notice that I need to apply DispatchQueue.main.async.
For instance,
Before applying DispatchQueue.main.async
extension ViewController:…

Cheok Yan Cheng
- 47,586
- 132
- 466
- 875
2
votes
0 answers
performFetch creating diffable data source snapshots with too much data
After executing an NSBatchBatchInsertRequest and calling fetchedResultsController.performFetch(), the frc’s delegate method controller(_:didChangeContentWith:) is called with a NSDiffableDataSourceSnapshot that…

Alex Walczak
- 1,276
- 1
- 12
- 27
2
votes
0 answers
UICollectionViewDiffableDataSource custom subclass initialization
So I am making a custom subclass of UICollectionViewDiffableDataSource.
My code looks like this :
class MyDiffableDataSource: UICollectionViewDiffableDataSource {
convenience required init(collectionView: UICollectionView)…
user15102768
2
votes
1 answer
How to stop UICollectionViewDiffableDataSource to scroll the collection view while we apply snapshot?
Is there any way that I can make UICollectionViewDiffableDataSource stop scrolling collection view while we apply snapshot?
I am using this library: https://github.com/ra1028/DiffableDataSources
I have a situation where I want to keep the collection…

Gaurav Parvadiya
- 149
- 2
- 11
2
votes
1 answer
diffable data source section header blinks during update
I'm currently facing the issue, that when applying a new snapshot to my current data source, that the header, footer and decoration views are not part of the collection view's subviews, which can be noticed as a weird flicker. Did anyone face that…

Carsten
- 581
- 4
- 17
2
votes
2 answers
Diffable Data Source with a custom collection view layout?
Here I have created a sample app that uses diffable data source for a collection view with a custom collection view layout. The specific layout I am using is from this tutorial.
Here is the relevant part of the code if you don't want to clone the…

BigBoy1337
- 4,735
- 16
- 70
- 138
2
votes
1 answer
Crash number of items in section 0 when there are only 0 sections in the collection view
I want to learn using UICollectionViewDiffableDataSource using Pinterest Layout, but when I try to running my simulator. it crash and give me a message
request for number of items in section 0 when there are only 0 sections in the collection…

ferryawijayanto
- 569
- 4
- 18
1
vote
0 answers
Diffable Data Source With Multiple Sections And Objects
I have a Data Source with multiple sections and objects. When creating my Data Source I can only access the section or the item type. I need to access both, is there a cleaner way to do this? My model is below;
enum BrowseSectionType: Hashable {
…

David Henry
- 1,972
- 20
- 43