Question

I have tableViewCell with 2 UICollectionView. Second UICollectionView is second part of first. First collections are in DataSource array. How can I set UICollectionViewCell for second UICollectionView?

Or I need to connect second UICollectionViews to DataSource? It is not good because first UICollectionView is for wall post. Second for repost.

Was it helpful?

Solution

If you want to use two UICollectionviews on the same view controller simply set their tags to 0 and 1 and add checks to your UICollectionview delegate methods to check for each tag before filling data from your models.

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{

if (collectionView.tag == 0)
{
//<<<DO Stuff for Collection view tagged 0 here >>>
}
}
else if (collectionview.tag == 1)
{
//<<<DO Stuff for Collection view tagged 1 here >>>
}

and

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
    {
    if (collectionView.tag == 0)
    {
    //  return <<<Return number of items in collectionview with tag 0>>>;
    }
    else
    {
     // return <<<Return number of items in collectionview with tag 1>>>;
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top