Gabriel Ribeiro Gabriel Ribeiro - 6 days ago 4
Swift Question

UICollectionView inside UICollectionViewCell

I'm struggling to find a way do something like this:
I'm using mostly UICollectionView to make my custom lists. And this time I want to add another UICollectionView inside a UICollectionViewCell.
The Layout is formed by a list of card, containing the informations below and inside it a list of items that came inside the same array.

Any ideias of how should I do this?

P.S: I'm not concerned about performance or something like this. So any idea would be welcome.

List inside another list

Answer

I managed to do this in another way. Instead of embed a UICollectionView inside another, I iterated through the array of elements and created subviews above the label.

if let item = info["PRODUTOSITENS"] as? [[String:Any]] {
          for produto in item {
            // All the business logic
                          let DynamicView = UIView(frame: CGRect(x:Double(cell.status.frame.origin.x), y:y, width:Double(collectionView.frame.size.width - 20.0), height:80.0))
            cell.addSubview(DynamicView)
        }
    }