2016-06-24 3 views

答えて

1

これを試してください。あなたのsizeForItemAtIndexPath機能を私のものに変更してください。条件は2つの異なる細胞を返すために、場合

- (CGSize)collectionView:(UICollectionView *)collectionView 
      layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { 
    if (indexPath.row%3==0) { 
     return CGSizeMake(self.collectionView.frame.size.width, 80); 
    } 
    CGFloat minSpace = 10; //Set this minSpace for space that you want between two cell 
    return CGSizeMake((self.collectionView.frame.size.width - minSpace)/2, 80); 
} 

もこれであなたのcellForItemAtIndexPathかの条件を変更してください。あなたが持っている場合。

希望すると、これが役立ちます。

+0

に動作していないバディ –

+0

ようこそをとることによって、テーブルビューでこれを達成することができます:) –

1

ターゲットセルのインデックス順の順序は、......識別するための注文は0であり、、1,2、、4,5- 、7,8- あります3,6,9 ... indexpathのアイテムに対応するサイズのコードは、あなたのストーリーボードで

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


    NSUInteger pos = indexPath.row; 
    if(pos%3==0) 
    { 
     return CGSizeMake(dynamicCollection.frame.size.width-10, 80); 

    } 
    else 
    { 
     return CGSizeMake(dynamicCollection.frame.size.width/2-10, 80); 
    } 

} 

はセクション5,5,5,5のためのインセットを提供する必要があります。 collectionviewとin scale属性を選択します。

enter image description here

+0

私が間違ってやっていたところ、私が見つかりました。とにかく感謝します。これを+1してください。 –

関連する問題