簡體   English   中英

旋轉時未調用UICollectionViewDelegateFlowLayout方法

[英]UICollectionViewDelegateFlowLayout methods not called on rotation

在我的集合視圖布局( UICollectionViewFlowLayout的子類)中,我定義了:

- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds {
    return YES;
}

我的期望是,由於旋轉是一個邊界變化,我的布局將重新計算。 但是,當我在以下位置設置斷點時:

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

屏幕旋轉時不會觸發斷點。 有誰知道為什么?

collectionView:layout:sizeForItemAtIndexPath:方法應該在UI CollectionViewDelegate類的類中實現。 不在UICollectionViewLayout的子類中。 你在哪里實現的?

PS。 沒有必要同時使用兩者。 如果您有自定義UICollectionViewLayout類,請使用layoutAttributesForItemAtIndexPath:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM