2014-09-06 47 views
0

在带有流布局的UICollectionView中,我想使用itemSize而不是itemSizeForCellAtIndexPath,因为单元格的大小对于每个方向都是不变的。但是,单元格的大小取决于视图控制器视图的大小,直到运行时才确定它的大小。当itemSize更改为不同方向时,何时在UICollectionViewFlowLayout中设置itemSize?

什么时候设置itemSize是正确的时间?

+0

您使用的是自动布局? – rptwsthi 2014-09-06 13:25:55

回答

0

那么因为我不知道你是否使用AutoLayout或不我会建议你两个。

if (using AutoLayout) 
    set it inside: -(void)viewDidLayoutSubviews 
else 
    set it inside: - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation