UICollection View调整屏幕大小的单元大小

目前我有一个采集视图占用我的大部分屏幕在3.5英寸的屏幕大小。集合视图是从顶部51像素,从屏幕的底部20像素。 我正在使用UIPageControl的单元UIPageControl来创build分页布局,每页一个单元格。 当切换到4英寸的大小,使用约束我可以得到collections视图扩大到新的空间(保持51像素从顶部和20从底部),但单元格大小保持不变,所以现在有一堆在单元格顶部和底部的空白空间。 我尝试使用约束,但似乎你不能为单元格设置它们。 如何扩大单元尺寸以填充iPhone 5上的空白空间?

集合视图代码是刚刚

 - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { MyCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath]; return cell; } 

布局在IB中设置我想在添加更多内容之前先让布局工作

iPhone 5视图。我想填补空白空间

iPhone 4视图

您可以使用UICollectionViewFlowLayout方法的itemSize属性来设置UICollectionViewCell大小,或者使用delegate方法collectionView:layout:sizeForItemAtIndexPath:如果您需要dynamic设置UICollectionViewCells的大小。

 CollectionView layout Delegate that will help you to resize your Cell as you need. 
 - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath;