How to build a UICollectionView like the App Store
Why Stack Overflow recommends it
Stack Overflow users link it when answering or asking about iOS compositional layouts, diffable data sources, and recreating the App Store's multi-section collection view.
Recommended by 4 people across 4 different months, 2019 to 2023.
What it is
Paul Hudson of Hacking with Swift builds an App Store-style screen on iOS 13 using UICollectionViewCompositionalLayout and UICollectionViewDiffableDataSource. It is a 50-minute follow-along coding tutorial with source code published on GitHub as TapStore.
What people said
Recommends Tiago Almeida · 2019-10 · Stack Overflow · on “How to snap horizontal paging to multi-row collection view like App Store?”
With iOS 13 this became a lot easier! In iOS 13 you can use a UICollectionViewCompositionalLayout . This introduces a couple of concepts and I will try to give a gist over here, but I think is worth a lot to understand this! Concepts In a CompositionalLayout you have 3 entities that allow you to specify sizes. You can specify sizes using absolute values, fractional values (half, for instance) or estimates. The 3 entities are: Item ( NSCollectionLayoutItem ) Your cell size. Fractional sizes are relative to the group the item is in and they can consider the width or the height of the parent. Group ( NSCollectionLayoutGroup ) Groups allow you to create a set of items. In that app store example,
Recommends codingChicken · 2021-03 · Stack Overflow · on “Why is it possible to write the UICollectionViewDiffableDataSource initializer in this strange way?”
While learning Swift via Paul Hudsons's tutorial [this video] , I came across something strange. The initializer of UICollectionViewDiffableDataSource is defined as: public init(collectionView: UICollectionView, cellProvider: @escaping UICollectionViewDiffableDataSource<SectionIdentifierType, ItemIdentifierType>.CellProvider) There is no other initializer as far as I can tell. However, Paul successfully initializes it like this, leaving out the cellProvider argument: dataSource = UICollectionViewDiffableDataSource<Section, App>(collectionView: collectionView) { collectionView, indexPath, app in switch self.sections[indexPath.section].type { case "mediumTable": return self.configure(MediumTableCel
Recommends SeaSpell · 2021-07 · Stack Overflow · on “App Store - ratings and reviews - table view or collection view?”
I just ran across this video yesterday talking about the collection view layouts of the App Store. You should check it out. He also put a git-hub repo of the code. [this video] In your case you could use collection view or table view or any combination of the two.
Recommends Ptit Xav · 2023-03 · Stack Overflow · on “Collectionview in TableView - How Perform segue? - Swift”
You should try to look at compositional layout for your needs. You only need 1 collection view.. see this great example [this video]
Cites JBZic · 2021-06 · Stack Overflow · on “Where do the parameters come from in the UICollectionViewDiffableDataSource closure?”
Having trouble understanding the closure in UICollectionViewDiffableDataSource , particularly what's being passed into it. All of the tutorials I can find explain what to type but not why , and I'm still a bit new to Swift and programming. I'm following along with Paul Hudson's tutorial [this video] (he's making an app store made up of App objects) and in createDataSource() he writes: dataSource = UICollectionViewDiffableDataSource<Section, App>(collectionView: collectionView) { collectionView, indexPath, app in //rest of the closure } My confusion on the closure's parameters is about where they're coming from: He happens to declare collectionView as a global variable elsewhere in the View Contro
Cites Aditya Vyavahare · 2023-11 · Stack Overflow · on “How to implement custom paging on UICollectionView to make it appear like the one in the AppStore?”
Here's the solution: var imagesColletionView: UICollectionView! extension ViewController: UICollectionViewDelegate, UICollectionViewDataSource { func setupCollectionView() { imagesColletionView = UICollectionView(frame: view.bounds, collectionViewLayout: createCompositionalLayout()) imagesColletionView.autoresizingMask = [.flexibleWidth, .flexibleHeight] imagesColletionView.backgroundColor = .systemBackground imagesColletionView.delegate = self imagesColletionView.dataSource = self imagesColletionView.register(CustomCollectionViewCell.self, forCellWithReuseIdentifier: CustomCollectionViewCell.cellIdentifier) view.addSubview(imagesColletionView) imagesColletionView.isScrollEnabled = false //d