I want to have a CollectionView in my Header that resembles that on Instagram and Snapchat for my main CollectionView which would be the feed. When I try to add the collectionview from the library and set the header as delegate and datasource after implementing the delegate methods, I still dont see anything in the header.
//let layout = UICollectionViewFlowLayout()
let headerCollection = UICollectionView(frame: CGRect(x: 0, y: 0, width: 50, height: 90), collectionViewLayout: UICollectionViewFlowLayout())
override func awakeFromNib() {
super.awakeFromNib()
// headerCollection.delegate = self
// headerCollection.dataSource = self
}
}
extension HeaderforFeed: UICollectionViewDataSource, UICollectionViewDelegate{
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return CollectionViewData.Dict_StrImg.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = UICollectionViewCell(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
cell.backgroundColor = .red
return cell
}
}```
Based on your code, I would think that the issue is you are not adding it to the header (I understand it as a header section inside your UICollectionView). If it's so, try add it at
Here, you would add your custom view with
UICollectionViewasUICollectionReusableViewI don't know if this could help you, but according to your question is what I understood