user3531491
user3531491

Reputation: 5

UICollectionView indexes

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.

Upvotes: 0

Views: 112

Answers (1)

DavidNorman
DavidNorman

Reputation: 1461

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>>>;
    }
}

Upvotes: 3

Related Questions