The uicollectionview has n sections (say 1,2,3) that has m subsections (say 1.1,1.2 etc) which further branches into inner subsections (1.1.1, 1.1.2 etc) which finally has X no. of rows in it.
Asked
Active
Viewed 684 times
2 Answers
0
Why not just use three collection views and three screens?
Tap on Section 1
creates second screen with collection view with sections Subsection 1
and Subsection 2
.
Then tap on Subsection 1
creates third screen with collection view with sections Row 1
, Row 1
, Row 1
, Row 1
.

12357665
- 36
- 5
-
No there should be no animations involved except horizontal and vertical scrolling. – Dracarys May 11 '22 at 13:47
-
@Dracarys If you need animations, then consider [new API](https://developer.apple.com/documentation/uikit/views_and_controls/collection_views/implementing_modern_collection_views): compositional layout and diffable datasource. – 12357665 May 11 '22 at 14:09
0
I've implemented this using UICollectionViewCompositionalLayout. Used the
UICollectionViewCompositionalLayout { [self] (sectionNumber, environment) -> NSCollectionLayoutSection? in .... }
closure to setup the layout items and group them vertically and horizontally to form the layout for the entire section.
For reference -
To create an individual item (H: 50, W: 50) -
let item = NSCollectionLayoutItem(layoutSize: NSCollectionLayoutSize(widthDimension: .absolute(50), heightDimension: .absolute(50)))
To create groups (Horizontal) -
let group = NSCollectionLayoutGroup.horizontal(layoutSize:
NSCollectionLayoutSize(widthDimension:
.absolute(item.layoutSize.widthDimension.dimension * CGFloat((data.count))),
heightDimension: .estimated(50)), subitem: item, count: (data.count))
Group - vertical
let subGroup = NSCollectionLayoutGroup.vertical(layoutSize:
NSCollectionLayoutSize(widthDimension:
.absolute(CGFloat(width)),
heightDimension:
.absolute(heightForIndividualItem * CGFloat(data.count))),
subitems: group)

Dracarys
- 31
- 1
- 9