Expand a UICollectionView in the middle of rows

I have a UICollectionView like following:

Is it possible to add scrollable content in the middle of rows on click of a cell like following: 在这里输入图像描述

If yes, then how?


You can use this sample to your own need.

Expandable UICollectionView


What you can do is create 2 custom UICollectionView layouts. One without spacing and another one with it. Then animate change of the layout using method:

setCollectionViewLayout:animated:completion:

I'm going to have to assume you're using UICollectionViewFlowLayout for this purpose.

What you can simply do is add a new Cell at the desired indexPath and in the sizeForItemAtIndexPath datasource method, return the desired size (full width, required height). The flow layout will handle the rest for you.

Inside that cell, you can use a UIScrollView to get the Scrollable Content.

Update

Your cellForItemAtIndexPath:(NSIndexPath *)indexPath will look something like this

if(indexPath.item == myItemIndex && indexPath.section == myItemSection)
{
    return CGSizeMake(768,200);
}
else
{
    return CGSizeMake(128,128);
}

The values above are just examples. Modify them to suit your needs.

链接地址: http://www.djcxy.com/p/20204.html

上一篇: 使用自定义距离度量来对经纬度对进行聚类

下一篇: 在行的中间展开一个UICollectionView