我有2个UICollectionView的tableViewCell。第二个UICollectionView是第一个的第二部分。第一个集合在DataSource数组中。如何为第二个UICollectionView设置UICollectionViewCell?
或者我需要将第二个UICollectionViews连接到DataSource? 这不好,因为第一个UICollectionView用于墙贴。第二次重新发布。
答案 0 :(得分:3)
如果要在同一个视图控制器上使用两个UICollectionviews,只需将其标记设置为0和1,并在从模型中填充数据之前,将检查添加到UICollectionview委托方法中以检查每个标记。
-(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 >>>
}
和
-(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>>>;
}
}