Ios UICollectionViewDelegateFlowLayout方法在旋转时未调用

Ios UICollectionViewDelegateFlowLayout方法在旋转时未调用,ios,ios8,uikit,uicollectionview,Ios,Ios8,Uikit,Uicollectionview,在我的集合视图布局(UICollectionViewFlowLayout的子类UICollectionViewFlowLayout)中,我定义了: - (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds { return YES; } 我的期望是,由于旋转是一个边界变化,我的布局将得到重新计算。但是,当我在中设置断点时: - (CGSize)collectionView:(UICollectionView *)co

在我的集合视图布局(UICollectionViewFlowLayout的子类
UICollectionViewFlowLayout
)中,我定义了:

- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds {
    return YES;
}
我的期望是,由于旋转是一个边界变化,我的布局将得到重新计算。但是,当我在中设置断点时:

- (CGSize)collectionView:(UICollectionView *)collectionView
                  layout:(UICollectionViewLayout *)collectionViewLayout
  sizeForItemAtIndexPath:(NSIndexPath *)indexPath {

屏幕旋转时不会触发断点。有人知道原因吗?

collectionView:layout:sizeForItemAtIndexPath:方法应该在UI CollectionViewDelegate类的类中实现。不在UICollectionViewLayout的子类中。 你在哪里实施的


另外,没有必要同时使用这两种方法。如果您有自定义UICollectionViewLayout类,请在作为集合视图的委托的视图控制器内改用layoutAttributesForItemAtIndexPath:

I实现的
collectionView:layout:SizeFormiteIndeXPath:
。使用
layoutAttributesForItemAtIndexPath:
对我不起作用。与CollectionViewDelegate在同一类中的collectionView:layout:sizeForItemAtIndexPath的实现对我起作用。。