Multiple UICollectionView in the same ViewController
ios, uicollectionview, uicollectionviewlayout
Solution
it's simple
for every UICollectionView Delegates
- (NSUInteger)maximumNumberOfColumnsForCollectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout
- (CGFloat)collectionView:(UICollectionView*)collectionView layout:(UICollectionViewLayout*)collectionViewLayout
heightForItemAtIndexPath:(NSIndexPath*)indexPath
- (UICollectionViewCell*)collectionView:(UICollectionView*)collectionView
cellForItemAtIndexPath:(NSIndexPath*)indexPath
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
- (NSInteger)collectionView:(UICollectionView*)collectionView numberOfItemsInSection:(NSInteger)section`
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView*)collectionView`
write condition inside:
if (collectionView == myCollectionView1)
{
// do this
}
else if (collectionView == myCollectionView2)
{
// do this
}
lets say for example in
- (NSInteger)collectionView:(UICollectionView*)collectionView numberOfItemsInSection:(NSInteger)section
{
if (collectionView == myCollectionView1)
{
return 12;
}
else if (collectionView == myCollectionView2)
{
return 7;
}
return 0;
}
Problem
I am using custom `UICollectionView` layout for having different size of cells and I am not able to have a section in this. Is it good idea to use multiple `UICollectionView`s in the same `UIViewController`? Any suggestion please?