How to fold UICollectionView sections

I initially tried to do this with two UICollectionViews stacked on top of each other. However, for its correct change there was a nightmare with Auto-layout (I am a new iOS developer, so this is more criticism of my skill than Auto-layou t). I would like to stack two sections of UICollectionView cells on top of each other, like this:

  +----------------------+ |+-Section 0---------->| | +-------+ +-------+ | | | | | | | | | | | | | | |Cell 0 | |Cell 1 |+-> | | | | | | | | | | | | | +-------+ +-------+ | +--Section 1---------->| | +-------+ +-------+ | | | | | | | | | | | | | | | | | | | | |Cell 0 | |Cell 1 |+-> | | | | | | | | | | | | | +-------+ +-------+ | | | +----------------------+ 

I am using a custom thread layout, but I'm not even sure where to start splitting my current 2 sections to stack them. My sections are currently folded as follows:

  +--------(Offscreen) | + +--------xxxx--------+v | Section 1 | Section 2 | +-----+ +-----+ | +-----+ +-------+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +-----+ +-----+ | +-----+ +-------+ | | | | | +-----+ +-----+ | +-----+ +-------+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +-----+ +-----+ | +-----+ +-------+ | | | | | xxxx | +--------xxxx--------+ 
+6
source share
1 answer

UICollectionView can scroll either vertically or horizontally, not both. If you have only two sections, as in the diagram, you can use two types of collection. But it’s better to think about a design, such as a table view, that contains collection views in each cell. To make the design flexible (horizontal and vertical scrolling with any number of sections). Anyway, the design is a bit complicated, you have to set up a table view cell to insert a collection view into it. Now UITableView will give you a vertical scroll with the ability to scroll each row horizontally ( UICollectionView )

+1
source

Source: https://habr.com/ru/post/958903/


All Articles