I have a list of items (blue), and within each item there is a collection of sub items (yellow). Will it be possible to replicate this layout in iOS with collection and table views?
I was going to create the blue items as a table view with custom cells. Then within this custom cell (blue), I was going to place a collection view (yellow items).
See diagrams
More specifically, the layout will be like the following, varying content in each blue item and they are expandable, the yellow items becoming visible when the item has been expanded.
UICollectionViews will work for both yellow and blue. In fact, collectionviews use "sections" and "cells" to organize your data visually. A section would be one of your "item groups" and a cell would be a "yellow square." The layout you have shown should be very simple to implement using UICollectionViewFLowLayoutDelegate methods. Just follow the Apple docs...
I wrote a collection view subclass that can help you achieve that layout: https://github.com/nazeehshoura/NExpandableCollectionView
Use UICollectionElementKindSectionHeader
to represent your blue items, and UICollectionViewCell
to represent your yellow items. NExpandableCollectionView will expand and show the yellow items when a corresponding blue item is clicked.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.