Questions tagged [uicollectionviewdiffabledatasource]
75 questions
1
vote
1 answer
DiffableDataSource CollectionView returning no items in section
Here is my class:
class MediaViewController: UIViewController{
var collectionView: UICollectionView! = nil
private lazy var dataSource = makeDataSource()
fileprivate typealias DataSource =…

BigBoy1337
- 4,735
- 16
- 70
- 138
1
vote
1 answer
Correct way to update model variable inside UICollectionViewDiffableDataSource in iOS
I'm developing an application with UICollectionViewDiffableDataSource. Everything works like a charm, in fact I've got my collectionView updated automatically when I add a new model. However I'm unable to see updated cell when I update one of my…

Bellots
- 1,703
- 3
- 19
- 29
0
votes
0 answers
In UICollectionViewDiffableDataSource is there any way to make Supplementary View's (Header/Footer) partial text clickable?
Recently I started using Diffable Datasource.
I have a section footer which has a text which should be partial clickable.
Let's say the footer is:
"To know more click here"
So if user taps the click here it will redirect to a link.
I know normally…

Mahi Al Jawad
- 46
- 6
0
votes
0 answers
dataSource.snapshot().itemIdentifiers(inSection:) works extremely inefficient
Consider an app that uses UICollectionViewDiffableDataSource for the data source of UICollectionView.
private func makeDataSource() -> DataSource {
return DataSource(collectionView: collectionView) { collectionView, indexPath, task in
…

Nominalista
- 4,632
- 11
- 43
- 102
0
votes
0 answers
UICollectionView compositional layout: re-use dequeued cell not working iOS 14
I'm using compositional list layout with diffable data source for my collection view, for some reason I have to re-use dequeued cell, so the code looks like:
let cell = referenceCell ?? collectionView.dequeue(MyCell.self, for:…

Heuristic
- 5,087
- 9
- 54
- 94
0
votes
0 answers
UICollectionView scroll to cell without loading initial cells
I have a UICollectionView using a UICompositionalLayout for the layout and a UIDiffableDataSource for the data source.
The layout is a horizontal layout with one item per page (think of a page view controller).
This works fine, but the problem is…

ashipma
- 423
- 5
- 15
0
votes
1 answer
How to create dynamic number of sections in diffable UICollectionView?
I know there is a way to decide the number of sections later on if we use the UICollectionView datasource.
func numberOfSections(in collectionView: UICollectionView) -> Int
Just want to know are there any way for diffable datasource?

yonlau
- 113
- 2
- 8
0
votes
0 answers
UICollectionViewDiffableDataSource with reference types as the data items
I have an existing class that's a data model. I want to use it as the model for a collection view using UICollectionViewDiffableDataSource. This class looks like this:
class DataItem: Hashable {
let id: String
var text: String
…

Mr.P
- 1,390
- 13
- 35
0
votes
0 answers
layout.sectionHeadersPinToVisibleBounds in UICollectionViewDiffableDataSource
I want to keep the header in a UICollectionViewDiffableDataSource, as I understand I can do it with layout.sectionHeadersPinToVisibleBounds, but it's not usable with my collectionView layout
private func createLayout() -> UICollectionViewLayout {
…

martin wotterman
- 195
- 7
0
votes
0 answers
UICollectionViewDiffableDataSource cellProvider closure deallocated reference
I've got my view controller setup like:
class HomeViewController: UIViewController {
unowned var viewModel: HomeViewModelInterface!
private lazy var collectionViewDataSource: UICollectionViewDiffableDataSource = {
…

Mr.P
- 1,390
- 13
- 35
0
votes
0 answers
Need to implement pagination on Collection views using Compositional layout / How to reset collectionViewLayout with new section without blinking?
I have 5 different section, 3 of them i load during initial call and the remaining 2 during scroll(pagination).
If I am creating UICollectionViewCompositionalLayout before hand then the data is getting loaded in the order NSCollectionLayoutSection…

Abhinav Jha
- 295
- 1
- 17
0
votes
0 answers
Why can't I set dataSource using UICollectionViewDiffableDataSource when I initialize my collectionView(programmatically)?
Sorry if I ask a dumb question first, But I have been wondering why this happen?
I have been using UICollectionViewDiffableDataSource on my project using storyboard, And I try to create collectionView programmatically currently, I found that I can't…

Krauser Huang
- 11
- 2
0
votes
0 answers
Swift: Accessing sections when using diffable data sources?
I have a collection view with multiple sections and eventually multiple cell types. I've read that we should avoid using indexPath with using diffable data sources. Is the way I currently access sections defeat the purpose of using diffable data…

VAlexander
- 86
- 6
0
votes
1 answer
Show different layout section if collection view section has no data to display
I am trying to implement a collection view that consists of the following sections:
User section: Showing the user's profile info (avatar, email, etc)
Children section: Showing the user's children (if available)
Statistics section: Showing the…

christostsang
- 1,701
- 3
- 27
- 46
0
votes
0 answers
UICollectionView snapshot takes too long to RE-apply
I have a UICollectionView with a large set of data source, e.g. 30000+ items; And the data source varies depending on screen orientation (ie. portrait, landscape), so I re-create and re-apply the snapshot whenever screen rotates.
What I noticed, is…

Heuristic
- 5,087
- 9
- 54
- 94