Ajay Dang Ajay Dang - 7 months ago 78
Objective-C Question

Multiple collection view on one view controller

I have 4

collection view
on one
view controller
and different data has to be fetched from api for every view controller.

The data has been fetched one by one but how to fetch data for all
collection view
at the same time.

As i know i can use
CollectionView DataSource
and delegate methods for once and i have to implement methods for 4 collection view in one but it app crashes giving error

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[HomeScreenViewController collectionView:cellForItemAtIndexPath:]: unrecognized selector sent to instance.

Can anyone tell me how to solve this problem??


I would strongly suggest that you use a separate UICollectionViewController for each of your collection views. This can be achieved easily in the InterfaceBuilder via ContainerViews.

Coordinating all four CollectionViews in one View Controller is possible - but ugly.

ViewController embedding multiple CollectionViewControllers via ContainerViews